Remove linking azure-storage-blobs in azure-data-tables tests and decouple storage-common test base from blobs (#6141)
* Remove linking azure-storage-blobs in azure-data-tables tests * Decouple storage-common tests and blobs by removing some dependency. * Remove dependency in test_base.hpp on certain headers from storage-common that aren't needed. * Remove pragma once that weren't needed, and reduce the blobs headers included to the specific ones. * Fix the copy/paste typo for account types in test_base.
This commit is contained in:
Родитель
99e0895a5d
Коммит
57cc679580
|
@ -13,7 +13,14 @@
|
|||
|
||||
namespace Azure { namespace Storage { namespace Blobs { namespace Models {
|
||||
|
||||
bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs);
|
||||
bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs)
|
||||
{
|
||||
return lhs.Id == rhs.Id && lhs.StartsOn.HasValue() == rhs.StartsOn.HasValue()
|
||||
&& (!lhs.StartsOn.HasValue() || lhs.StartsOn.Value() == rhs.StartsOn.Value())
|
||||
&& lhs.ExpiresOn.HasValue() == rhs.ExpiresOn.HasValue()
|
||||
&& (!lhs.ExpiresOn.HasValue() || lhs.ExpiresOn.Value() == rhs.ExpiresOn.Value())
|
||||
&& lhs.Permissions == rhs.Permissions;
|
||||
}
|
||||
|
||||
}}}} // namespace Azure::Storage::Blobs::Models
|
||||
|
||||
|
|
|
@ -19,19 +19,6 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace Azure { namespace Storage { namespace Blobs { namespace Models {
|
||||
|
||||
bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs)
|
||||
{
|
||||
return lhs.Id == rhs.Id && lhs.StartsOn.HasValue() == rhs.StartsOn.HasValue()
|
||||
&& (!lhs.StartsOn.HasValue() || lhs.StartsOn.Value() == rhs.StartsOn.Value())
|
||||
&& lhs.ExpiresOn.HasValue() == rhs.ExpiresOn.HasValue()
|
||||
&& (!lhs.ExpiresOn.HasValue() || lhs.ExpiresOn.Value() == rhs.ExpiresOn.Value())
|
||||
&& lhs.Permissions == rhs.Permissions;
|
||||
}
|
||||
|
||||
}}}} // namespace Azure::Storage::Blobs::Models
|
||||
|
||||
namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
constexpr static const char* StandardStorageConnectionStringValue = "";
|
||||
|
@ -79,11 +66,52 @@ namespace Azure { namespace Storage { namespace Test {
|
|||
TestBase::TearDown();
|
||||
}
|
||||
|
||||
std::string ParseConnectionStringAndGetAccountName(const std::string& connectionString)
|
||||
{
|
||||
std::map<std::string, std::string> connectionStringMap;
|
||||
|
||||
std::string::const_iterator cur = connectionString.begin();
|
||||
|
||||
while (cur != connectionString.end())
|
||||
{
|
||||
auto key_begin = cur;
|
||||
auto key_end = std::find(cur, connectionString.end(), '=');
|
||||
std::string key = std::string(key_begin, key_end);
|
||||
cur = key_end;
|
||||
if (cur != connectionString.end())
|
||||
{
|
||||
++cur;
|
||||
}
|
||||
|
||||
auto value_begin = cur;
|
||||
auto value_end = std::find(cur, connectionString.end(), ';');
|
||||
std::string value = std::string(value_begin, value_end);
|
||||
cur = value_end;
|
||||
if (cur != connectionString.end())
|
||||
{
|
||||
++cur;
|
||||
}
|
||||
|
||||
if (!key.empty() || !value.empty())
|
||||
{
|
||||
connectionStringMap[std::move(key)] = std::move(value);
|
||||
}
|
||||
}
|
||||
|
||||
auto getWithDefault = [](const std::map<std::string, std::string>& m,
|
||||
const std::string& key,
|
||||
const std::string& defaultValue = std::string()) {
|
||||
auto ite = m.find(key);
|
||||
return ite == m.end() ? defaultValue : ite->second;
|
||||
};
|
||||
|
||||
return getWithDefault(connectionStringMap, "AccountName");
|
||||
}
|
||||
|
||||
const std::string& StorageTest::StandardStorageAccountName()
|
||||
{
|
||||
const static std::string accountName
|
||||
= Azure::Storage::_internal::ParseConnectionString(StandardStorageConnectionString())
|
||||
.AccountName;
|
||||
= ParseConnectionStringAndGetAccountName(StandardStorageConnectionString());
|
||||
return accountName;
|
||||
}
|
||||
|
||||
|
@ -102,8 +130,7 @@ namespace Azure { namespace Storage { namespace Test {
|
|||
const std::string& StorageTest::PremiumFileAccountName()
|
||||
{
|
||||
const static std::string accountName
|
||||
= Azure::Storage::_internal::ParseConnectionString(PremiumFileConnectionString())
|
||||
.AccountName;
|
||||
= ParseConnectionStringAndGetAccountName(PremiumFileConnectionString());
|
||||
return accountName;
|
||||
}
|
||||
|
||||
|
@ -122,7 +149,7 @@ namespace Azure { namespace Storage { namespace Test {
|
|||
const std::string& StorageTest::AdlsGen2AccountName()
|
||||
{
|
||||
const static std::string accountName
|
||||
= Azure::Storage::_internal::ParseConnectionString(AdlsGen2ConnectionString()).AccountName;
|
||||
= ParseConnectionStringAndGetAccountName(AdlsGen2ConnectionString());
|
||||
return accountName;
|
||||
}
|
||||
|
||||
|
@ -204,9 +231,9 @@ namespace Azure { namespace Storage { namespace Test {
|
|||
return Azure::Core::_internal::StringExtensions::ToLower(RandomString(size));
|
||||
}
|
||||
|
||||
Storage::Metadata StorageTest::RandomMetadata(size_t size)
|
||||
Metadata StorageTest::RandomMetadata(size_t size)
|
||||
{
|
||||
Storage::Metadata result;
|
||||
Metadata result;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
result["meta" + LowercaseRandomString(5)] = RandomString(10);
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#include <azure/core/platform.hpp>
|
||||
#include <azure/core/test/test_base.hpp>
|
||||
#include <azure/identity/client_secret_credential.hpp>
|
||||
#include <azure/storage/blobs.hpp>
|
||||
#include <azure/storage/common/internal/constants.hpp>
|
||||
#include <azure/storage/common/storage_common.hpp>
|
||||
|
||||
#include <cctype>
|
||||
#include <chrono>
|
||||
|
@ -25,6 +22,8 @@
|
|||
|
||||
namespace Azure { namespace Storage {
|
||||
|
||||
using Metadata = Azure::Core::CaseInsensitiveMap;
|
||||
|
||||
namespace Test {
|
||||
|
||||
class StorageTest : public Azure::Core::Test::TestBase {
|
||||
|
@ -121,7 +120,7 @@ namespace Azure { namespace Storage {
|
|||
char RandomChar();
|
||||
std::string RandomString(size_t size = 10);
|
||||
std::string LowercaseRandomString(size_t size = 10);
|
||||
Storage::Metadata RandomMetadata(size_t size = 5);
|
||||
Metadata RandomMetadata(size_t size = 5);
|
||||
void RandomBuffer(char* buffer, size_t length);
|
||||
void RandomBuffer(uint8_t* buffer, size_t length)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,14 @@
|
|||
|
||||
namespace Azure { namespace Storage { namespace Blobs { namespace Models {
|
||||
|
||||
bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs);
|
||||
bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs)
|
||||
{
|
||||
return lhs.Id == rhs.Id && lhs.StartsOn.HasValue() == rhs.StartsOn.HasValue()
|
||||
&& (!lhs.StartsOn.HasValue() || lhs.StartsOn.Value() == rhs.StartsOn.Value())
|
||||
&& lhs.ExpiresOn.HasValue() == rhs.ExpiresOn.HasValue()
|
||||
&& (!lhs.ExpiresOn.HasValue() || lhs.ExpiresOn.Value() == rhs.ExpiresOn.Value())
|
||||
&& lhs.Permissions == rhs.Permissions;
|
||||
}
|
||||
|
||||
}}}} // namespace Azure::Storage::Blobs::Models
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "share_directory_client_test.hpp"
|
||||
|
||||
#include <azure/storage/common/crypt.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "share_file_client_test.hpp"
|
||||
|
||||
#include <azure/core/cryptography/hash.hpp>
|
||||
#include <azure/storage/blobs/blob_container_client.hpp>
|
||||
#include <azure/storage/blobs/block_blob_client.hpp>
|
||||
#include <azure/storage/common/crypt.hpp>
|
||||
#include <azure/storage/common/internal/file_io.hpp>
|
||||
#include <azure/storage/common/storage_common.hpp>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "share_client_test.hpp"
|
||||
|
||||
#include <azure/storage/common/crypt.hpp>
|
||||
#include <azure/storage/files/shares/share_sas_builder.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "queue_client_test.hpp"
|
||||
|
||||
#include <azure/storage/common/crypt.hpp>
|
||||
#include <azure/storage/queues/queue_sas_builder.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
|
|
@ -40,7 +40,7 @@ create_map_file(azure-data-tables-test azure-data-tables-test.map)
|
|||
# Include shared test headers
|
||||
target_include_directories(azure-data-tables-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../storage/azure-storage-common)
|
||||
|
||||
target_link_libraries(azure-data-tables-test PRIVATE azure-data-tables azure-storage-blobs azure-identity azure-core-test-fw gtest gtest_main gmock)
|
||||
target_link_libraries(azure-data-tables-test PRIVATE azure-data-tables azure-identity azure-core-test-fw gtest gtest_main gmock)
|
||||
|
||||
# gtest_discover_tests will scan the test from azure-data-tables-test and call add_test
|
||||
# for each test to ctest. This enables `ctest -r` to run specific tests directly.
|
||||
|
|
Загрузка…
Ссылка в новой задаче