Skip to content

Commit 9293a6d

Browse files
authored
blob test cases improvements (#4806)
* move not-working test assertion to a separate case * enable AppendBlobClientTest.HighThroughputAppendBlob_LIVEONLY_ * remove incorrect comment
1 parent 0a175f2 commit 9293a6d

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,36 @@ namespace Azure { namespace Storage { namespace Test {
327327
options2.TransactionalContentHash.Value().Value = contentMd5;
328328
EXPECT_NO_THROW(
329329
appendBlobClient2.AppendBlockFromUri(appendBlobClient.GetUrl() + GetSas(), options2));
330-
options2.TransactionalContentHash.Value().Algorithm = HashAlgorithm::Crc64;
331-
options2.TransactionalContentHash.Value().Value
332-
= Azure::Core::Convert::Base64Decode(DummyCrc64);
333-
// EXPECT_THROW(
334-
// appendBlobClient2.AppendBlockFromUri(appendBlobClient.GetUrl() + GetSas(), options2),
335-
// StorageException);
336-
options2.TransactionalContentHash.Value().Value = contentCrc64;
330+
}
331+
332+
TEST_F(AppendBlobClientTest, DISABLED_AppendBlockFromUriCrc64AccessCondition)
333+
{
334+
auto appendBlobClient = GetAppendBlobClientForTest(RandomString());
335+
336+
const std::vector<uint8_t> blobContent = RandomBuffer(10);
337+
const std::vector<uint8_t> contentCrc64
338+
= Azure::Storage::Crc64Hash().Final(blobContent.data(), blobContent.size());
339+
340+
appendBlobClient.Create();
341+
auto contentStream = Azure::Core::IO::MemoryBodyStream(blobContent.data(), blobContent.size());
342+
appendBlobClient.AppendBlock(contentStream);
343+
344+
auto appendBlobClient2 = GetAppendBlobClientForTest(RandomString());
345+
appendBlobClient2.Create();
346+
347+
Blobs::AppendBlockFromUriOptions options;
348+
options.TransactionalContentHash = ContentHash();
349+
options.TransactionalContentHash.Value().Algorithm = HashAlgorithm::Crc64;
350+
options.TransactionalContentHash.Value().Value = Azure::Core::Convert::Base64Decode(DummyCrc64);
351+
EXPECT_THROW(
352+
appendBlobClient2.AppendBlockFromUri(appendBlobClient.GetUrl() + GetSas(), options),
353+
StorageException);
354+
options.TransactionalContentHash.Value().Value = contentCrc64;
337355
EXPECT_NO_THROW(
338-
appendBlobClient2.AppendBlockFromUri(appendBlobClient.GetUrl() + GetSas(), options2));
356+
appendBlobClient2.AppendBlockFromUri(appendBlobClient.GetUrl() + GetSas(), options));
339357
}
340358

341-
TEST_F(AppendBlobClientTest, DISABLED_LIVEONLY_HighThroughputAppendBlob)
359+
TEST_F(AppendBlobClientTest, HighThroughputAppendBlob_LIVEONLY_)
342360
{
343361
auto appendBlobClient = m_blobContainerClient->GetAppendBlobClient(RandomString());
344362
appendBlobClient.Create();

sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,6 @@ namespace Azure { namespace Storage { namespace Test {
402402
EXPECT_TRUE(foundMetadata);
403403
}
404404

405-
// Test uses StartsOn and ExpiresOn values based on time now() + minutes
406-
// Hence, the test can't be recorded and need to run on live mode always.
407405
TEST_F(BlobContainerClientTest, AccessControlList)
408406
{
409407
auto containerClient = *m_blobContainerClient;

0 commit comments

Comments
 (0)