Skip to content

Commit

Permalink
Merge branch 'recordings-story' of github.com:vhvb1989/azure-sdk-for-…
Browse files Browse the repository at this point in the history
…cpp into recordings-story
  • Loading branch information
vhvb1989 committed Dec 30, 2021
2 parents ca80dde + 46c0c60 commit bd02af0
Show file tree
Hide file tree
Showing 128 changed files with 33,190 additions and 456 deletions.
5 changes: 2 additions & 3 deletions sdk/core/azure-core-test/inc/azure/core/test/test_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace Azure { namespace Core { namespace Test {
{
std::string updated(src);
std::replace(updated.begin(), updated.end(), '/', '-');
return updated;
return RemovePreffix(updated);
}

void SkipTest()
Expand Down Expand Up @@ -274,14 +274,13 @@ namespace Azure { namespace Core { namespace Test {
std::string recordingPath(baseRecordingPath);
recordingPath.append("/recordings");

m_testContext.TestMode = Azure::Core::Test::InterceptorManager::GetTestMode();
// Use the test info to init the test context and interceptor.
auto testNameInfo = ::testing::UnitTest::GetInstance()->current_test_info();

// set the interceptor for the current test
m_testContext.RenameTest(
Sanitize(testNameInfo->test_suite_name()), Sanitize(testNameInfo->name()));
m_testContext.RecordingPath = recordingPath;
m_testContext.TestMode = Azure::Core::Test::InterceptorManager::GetTestMode();
m_interceptor = std::make_unique<Azure::Core::Test::InterceptorManager>(m_testContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@

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;
}
bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs);

}}}} // namespace Azure::Storage::Blobs::Models

Expand Down
17 changes: 15 additions & 2 deletions sdk/storage/azure-storage-common/test/ut/test_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
#include <azure/core/internal/strings.hpp>
#include <azure/core/platform.hpp>

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 = "";
Expand Down Expand Up @@ -218,12 +231,12 @@ namespace Azure { namespace Storage { namespace Test {
return Azure::Core::_internal::StringExtensions::ToLower(RandomString(size));
}

Storage::Metadata StorageTest::RandomMetadata(size_t size)
Storage::Metadata StorageTest::GetMetadata(size_t size)
{
Storage::Metadata result;
for (size_t i = 0; i < size; ++i)
{
result["m" + LowercaseRandomString(5)] = RandomString(5);
result["meta" + std::to_string(i % 10)] = "value";
}
return result;
}
Expand Down
20 changes: 19 additions & 1 deletion sdk/storage/azure-storage-common/test/ut/test_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ namespace Azure { namespace Storage {
return Azure::Core::_internal::StringExtensions::ToLower(name);
}

std::string GetFileSystemValidName() const
{
std::string name(m_testContext.GetTestSuiteName() + m_testContext.GetTestName());
// Make sure the name is less than 63 characters long
auto const nameSize = name.size();
size_t const maxContainerNameSize = 63;
if (nameSize > maxContainerNameSize)
{
name = std::string(name.begin() + nameSize - maxContainerNameSize, name.end());
}
// Check name won't start with `-`
if (name[0] == '-')
{
name = std::string(name.begin() + 1, name.end());
}
return Azure::Core::_internal::StringExtensions::ToLower(name);
}

std::string GetTestEncryptionScope()
{
static const std::string TestEncryptionScope("EncryptionScopeForTest");
Expand All @@ -79,7 +97,7 @@ namespace Azure { namespace Storage {

std::string LowercaseRandomString(size_t size = 10);

Storage::Metadata RandomMetadata(size_t size = 5);
Storage::Metadata GetMetadata(size_t size = 5);

void RandomBuffer(char* buffer, size_t length);
inline void RandomBuffer(uint8_t* buffer, size_t length)
Expand Down
23 changes: 3 additions & 20 deletions sdk/storage/azure-storage-files-datalake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,9 @@ az_rtti_setup(
# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
create_code_coverage(storage azure-storage-files-datalake azure-storage-test "tests?/*;samples?/*")

# if(BUILD_TESTING)
# target_sources(
# azure-storage-test
# PRIVATE
# test/datalake_directory_client_test.cpp
# test/datalake_directory_client_test.hpp
# test/datalake_file_client_test.cpp
# test/datalake_file_client_test.hpp
# test/datalake_file_system_client_test.cpp
# test/datalake_file_system_client_test.hpp
# test/datalake_path_client_test.cpp
# test/datalake_path_client_test.hpp
# test/datalake_sas_test.cpp
# test/datalake_service_client_test.cpp
# test/datalake_service_client_test.hpp
# test/macro_guard.cpp
# )

# target_link_libraries(azure-storage-test PRIVATE azure-storage-files-datalake)
# endif()
if(BUILD_TESTING)
add_subdirectory(test/ut)
endif()

if(BUILD_STORAGE_SAMPLES)
add_subdirectory(samples)
Expand Down
44 changes: 44 additions & 0 deletions sdk/storage/azure-storage-files-datalake/test/ut/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT

cmake_minimum_required (VERSION 3.13)

project (azure-storage-files-datalake-test LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include(GoogleTest)

# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")

add_executable (
azure-storage-files-datalake-test
datalake_directory_client_test.cpp
datalake_directory_client_test.hpp
datalake_file_client_test.cpp
datalake_file_client_test.hpp
datalake_file_system_client_test.cpp
datalake_file_system_client_test.hpp
datalake_path_client_test.cpp
datalake_path_client_test.hpp
datalake_sas_test.cpp
datalake_service_client_test.cpp
datalake_service_client_test.hpp
macro_guard.cpp
# Include shared test source code
${CMAKE_CURRENT_SOURCE_DIR}/../../../azure-storage-common/test/ut/test_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../../azure-storage-common/test/ut/test_base.hpp
)

# Include shared test headers
target_include_directories(azure-storage-files-datalake-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../azure-storage-common)

target_link_libraries(azure-storage-files-datalake-test PRIVATE azure-storage-files-datalake azure-identity azure-core-test-fw gtest gtest_main gmock)

# gtest_discover_tests will scan the test from azure-storage-files-datalake-test and call add_test
# for each test to ctest. This enables `ctest -r` to run specific tests directly.
gtest_discover_tests(azure-storage-files-datalake-test
TEST_PREFIX azure-storage-files-datalake.
NO_PRETTY_TYPES
NO_PRETTY_VALUES)
Loading

0 comments on commit bd02af0

Please sign in to comment.