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

Commit

Permalink
Merge branch 'release/0.5' into bug/iscroggin/KEP-1239-1
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelsavannah committed Mar 14, 2019
2 parents 8f300c9 + 3dcda61 commit 86aae85
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
12 changes: 10 additions & 2 deletions crud/crud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,16 @@ crud::handle_read(const bzn::caller_id_t& /*caller_id*/, const database_msg& req

if (result)
{
response.mutable_read()->set_key(key);
response.mutable_read()->set_value(*result);
if (request.msg_case() == database_msg::kRead)
{
response.mutable_read()->set_key(key);
response.mutable_read()->set_value(*result);
}
else
{
response.mutable_quick_read()->set_key(key);
response.mutable_quick_read()->set_value(*result);
}
}

this->send_response(request, (result) ? bzn::storage_result::ok : bzn::storage_result::not_found, std::move(response), session);
Expand Down
12 changes: 6 additions & 6 deletions crud/test/crud_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@ TEST(crud, test_that_read_sends_proper_response)
// quick read key...
msg.release_read();
msg.mutable_quick_read()->set_key("key");
expect_response(session, "uuid", uint64_t(123), database_response::kRead, std::nullopt,
expect_response(session, "uuid", uint64_t(123), database_response::kQuickRead, std::nullopt,
[](const auto& resp)
{
ASSERT_EQ(resp.read().key(), "key");
ASSERT_EQ(resp.read().value(), "value");
ASSERT_EQ(resp.quick_read().key(), "key");
ASSERT_EQ(resp.quick_read().value(), "value");
});

crud.handle_request("caller_id", msg, session);
Expand Down Expand Up @@ -413,9 +413,9 @@ TEST(crud, test_that_point_of_contact_read_sends_proper_response)
ASSERT_TRUE(parse_env_to_db_resp(resp, msg->SerializeAsString()));
ASSERT_EQ(resp.header().db_uuid(), "uuid");
ASSERT_EQ(resp.header().nonce(), uint64_t(123));
ASSERT_EQ(resp.response_case(), database_response::kRead);
ASSERT_EQ(resp.read().key(), "key");
ASSERT_EQ(resp.read().value(), "value");
ASSERT_EQ(resp.response_case(), database_response::kQuickRead);
ASSERT_EQ(resp.quick_read().key(), "key");
ASSERT_EQ(resp.quick_read().value(), "value");
}));

crud.handle_request("caller_id", msg, nullptr);
Expand Down
13 changes: 7 additions & 6 deletions proto/database.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ message database_response
database_redirect_response redirect = 2;
database_subscription_update subscription_update = 3;
database_read_response read = 4;
database_has_response has = 5;
database_keys_response keys = 6;
database_size_response size = 7;
database_error error = 8;
database_has_db_response has_db = 9;
database_writers_response writers = 10;
database_read_response quick_read = 5;
database_has_response has = 6;
database_keys_response keys = 7;
database_size_response size = 8;
database_error error = 9;
database_has_db_response has_db = 10;
database_writers_response writers = 11;
}
}

Expand Down

0 comments on commit 86aae85

Please sign in to comment.