|
|
|
@ -32,13 +32,14 @@ class ClientContextTestPeer { |
|
|
|
|
explicit ClientContextTestPeer(ClientContext* const ctx) : ctx_(ctx) {} |
|
|
|
|
|
|
|
|
|
/// Inject metadata to the ClientContext for the test. The test peer
|
|
|
|
|
/// ##must be alive when a ClientContext::GetServerInitialMetadata is
|
|
|
|
|
/// called.
|
|
|
|
|
void AddMetadata(const std::string& key, const std::string& value) { |
|
|
|
|
initial_metadata_storage_.insert( |
|
|
|
|
/// must be alive when a ClientContext::GetServerInitialMetadata is called.
|
|
|
|
|
void AddServerInitialMetadata(const std::string& key, |
|
|
|
|
const std::string& value) { |
|
|
|
|
server_initial_metadata_storage_.insert( |
|
|
|
|
std::pair<std::string, std::string>(key, value)); |
|
|
|
|
ctx_->initial_metadata_received_ = true; |
|
|
|
|
ctx_->recv_initial_metadata_.map()->clear(); |
|
|
|
|
for (const auto& item : initial_metadata_storage_) { |
|
|
|
|
for (const auto& item : server_initial_metadata_storage_) { |
|
|
|
|
ctx_->recv_initial_metadata_.map()->insert( |
|
|
|
|
std::pair<grpc::string_ref, grpc::string_ref>( |
|
|
|
|
item.first.c_str(), |
|
|
|
@ -52,7 +53,7 @@ class ClientContextTestPeer { |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
ClientContext* const ctx_; // not owned
|
|
|
|
|
std::multimap<std::string, std::string> initial_metadata_storage_; |
|
|
|
|
std::multimap<std::string, std::string> server_initial_metadata_storage_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} // namespace testing
|
|
|
|
|