diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-04 12:25:20 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-05 13:32:39 +0200 |
commit | 5140befaa10f65145fe041b416b7764127efc379 (patch) | |
tree | 9bb8d66c31455d275e5870e69c10d31789fb6c0a /test/buildtool/execution_api/local/local_api.test.cpp | |
parent | e8992e622278d093165b3a0d8271a14424b61775 (diff) | |
download | justbuild-5140befaa10f65145fe041b416b7764127efc379.tar.gz |
Convert Storage to a general class
Diffstat (limited to 'test/buildtool/execution_api/local/local_api.test.cpp')
-rw-r--r-- | test/buildtool/execution_api/local/local_api.test.cpp | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/test/buildtool/execution_api/local/local_api.test.cpp b/test/buildtool/execution_api/local/local_api.test.cpp index fa296c9b..de875a2c 100644 --- a/test/buildtool/execution_api/local/local_api.test.cpp +++ b/test/buildtool/execution_api/local/local_api.test.cpp @@ -23,10 +23,21 @@ #include "test/utils/hermeticity/local.hpp" namespace { +class FactoryApi final { + public: + explicit FactoryApi( + gsl::not_null<Storage const*> const& storage, + gsl::not_null<StorageConfig const*> const& storage_config) noexcept + : storage_{*storage}, storage_config_{*storage_config} {} -auto const kApiFactory = []() { - return IExecutionApi::Ptr{ - new LocalApi(&StorageConfig::Instance(), &Storage::Instance())}; + [[nodiscard]] auto operator()() const -> IExecutionApi::Ptr { + return IExecutionApi::Ptr{ + new LocalApi{&StorageConfig::Instance(), &storage_}}; + } + + private: + Storage const& storage_; + StorageConfig const& storage_config_; }; } // namespace @@ -34,51 +45,67 @@ auto const kApiFactory = []() { TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: No input, no output", "[execution_api]") { - TestNoInputNoOutput(kApiFactory, {}, /*is_hermetic=*/true); + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); + TestNoInputNoOutput(api_factory, {}, /*is_hermetic=*/true); } TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: No input, create output", "[execution_api]") { - TestNoInputCreateOutput(kApiFactory, {}, /*is_hermetic=*/true); + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); + TestNoInputCreateOutput(api_factory, {}, /*is_hermetic=*/true); } TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: One input copied to output", "[execution_api]") { - TestOneInputCopiedToOutput(kApiFactory, {}, /*is_hermetic=*/true); + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); + TestOneInputCopiedToOutput(api_factory, {}, /*is_hermetic=*/true); } TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: Non-zero exit code, create output", "[execution_api]") { - TestNonZeroExitCodeCreateOutput(kApiFactory, {}); + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); + TestNonZeroExitCodeCreateOutput(api_factory, {}); } TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: Retrieve two identical trees to path", "[execution_api]") { + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); TestRetrieveTwoIdenticalTreesToPath( - kApiFactory, {}, "two_trees", /*is_hermetic=*/true); + api_factory, {}, "two_trees", /*is_hermetic=*/true); } TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: Retrieve file and symlink with same content to " "path", "[execution_api]") { + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); TestRetrieveFileAndSymlinkWithSameContentToPath( - kApiFactory, {}, "file_and_symlink", /*is_hermetic=*/true); + api_factory, {}, "file_and_symlink", /*is_hermetic=*/true); } TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: Retrieve mixed blobs and trees", "[execution_api]") { + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); TestRetrieveMixedBlobsAndTrees( - kApiFactory, {}, "blobs_and_trees", /*is_hermetic=*/true); + api_factory, {}, "blobs_and_trees", /*is_hermetic=*/true); } TEST_CASE_METHOD(HermeticLocalTestFixture, "LocalAPI: Create directory prior to execution", "[execution_api]") { - TestCreateDirPriorToExecution(kApiFactory, {}, /*is_hermetic=*/true); + auto const storage = Storage::Create(&StorageConfig::Instance()); + FactoryApi api_factory(&storage, &StorageConfig::Instance()); + TestCreateDirPriorToExecution(api_factory, {}, /*is_hermetic=*/true); } |