Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
KEP-1290 Reading ttl of a persisted key (no expiry) results in RECORD…
Browse files Browse the repository at this point in the history
…_NOT_FOUND

KEP-1293 Setting persistence of a persisted key returns RECORD_NOT_FOUND
  • Loading branch information
ebruck committed Mar 28, 2019
1 parent c351d13 commit 2fcd40c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crud/crud.cpp
Expand Up @@ -372,7 +372,7 @@ crud::handle_ttl(const bzn::caller_id_t& /*caller_id*/, const database_msg& requ
}
}

this->send_response(request, (has) ? bzn::storage_result::ok : bzn::storage_result::not_found, std::move(response), session);
this->send_response(request, (has) ? bzn::storage_result::ok : bzn::storage_result::ttl_not_found, std::move(response), session);
}


Expand Down Expand Up @@ -413,7 +413,7 @@ crud::handle_persist(const bzn::caller_id_t& caller_id, const database_msg& requ
}
else
{
result = bzn::storage_result::not_found;
result = bzn::storage_result::ttl_not_found;
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions crud/test/crud_test.cpp
Expand Up @@ -305,7 +305,7 @@ TEST(crud, test_that_point_of_contact_create_sends_proper_response)
{
database_response resp;
ASSERT_TRUE(parse_env_to_db_resp(resp, msg->SerializeAsString()));
ASSERT_EQ(resp.error().message(), bzn::storage_result_msg.at(bzn::storage_result::not_found));
ASSERT_EQ(resp.error().message(), bzn::storage_result_msg.at(bzn::storage_result::ttl_not_found));
}));

crud->handle_request("caller_id", msg, nullptr);
Expand Down Expand Up @@ -2252,7 +2252,12 @@ TEST(crud, test_that_key_with_expiration_can_be_made_persistent)

// should be gone
msg.mutable_ttl()->set_key("key");
expect_signed_response(session, "uuid", 123, database_response::kError, bzn::storage_result_msg.at(bzn::storage_result::not_found));
expect_signed_response(session, "uuid", 123, database_response::kError, bzn::storage_result_msg.at(bzn::storage_result::ttl_not_found));
crud->handle_request("caller_id", msg, session);

// make key persist that no longer exists
msg.mutable_persist()->set_key("key");
expect_signed_response(session, "uuid", 123, database_response::kError, bzn::storage_result_msg.at(bzn::storage_result::ttl_not_found));
crud->handle_request("caller_id", msg, session);
}

Expand Down
2 changes: 2 additions & 0 deletions storage/storage_base.hpp
Expand Up @@ -30,6 +30,7 @@ namespace bzn
ok=0,
not_found,
exists,
ttl_not_found,
not_saved,
value_too_large,
key_too_large,
Expand All @@ -43,6 +44,7 @@ namespace bzn
{storage_result::ok, "OK"},
{storage_result::not_found, "RECORD_NOT_FOUND"},
{storage_result::exists, "RECORD_EXISTS"},
{storage_result::ttl_not_found, "TTL_RECORD_NOT_FOUND"},
{storage_result::not_saved, "NOT_SAVED"},
{storage_result::value_too_large, "VALUE_SIZE_TOO_LARGE"},
{storage_result::key_too_large, "KEY_SIZE_TOO_LARGE"},
Expand Down

0 comments on commit 2fcd40c

Please sign in to comment.