fix regression on contex value implementation for Storage (#1862)

This commit is contained in:
Victor Vazquez 2021-03-11 07:53:33 +00:00 committed by GitHub
parent 23b698f2c6
commit c0ce9688d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -177,9 +177,17 @@ struct SomeStructForContext
int someField = 12345;
};
TEST(Context, UniquePtr)
TEST(Context, InstanceValue)
{
auto contextP = Context::GetApplicationContext().WithValue("struct", SomeStructForContext());
auto& contextValueRef = contextP.Get<SomeStructForContext>("struct");
EXPECT_EQ(contextValueRef.someField, 12345);
}
TEST(Context, UniquePtr)
{
auto contextP = Context::GetApplicationContext().WithValue(
"struct", std::make_unique<SomeStructForContext>());
auto& contextValueRef = contextP.Get<std::unique_ptr<SomeStructForContext>>("struct");
EXPECT_EQ(contextValueRef->someField, 12345);
}

View File

@ -13,7 +13,9 @@ namespace Azure { namespace Storage { namespace _detail {
SecondaryHostReplicaStatus* replicaStatus = nullptr;
if (ctx.HasKey(SecondaryHostReplicaStatusKey))
{
replicaStatus = ctx.Get<SecondaryHostReplicaStatus*>(SecondaryHostReplicaStatusKey);
replicaStatus
= ctx.Get<std::unique_ptr<SecondaryHostReplicaStatus>>(SecondaryHostReplicaStatusKey)
.get();
}
bool considerSecondary = (request.GetMethod() == Azure::Core::Http::HttpMethod::Get