summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/common/api_test.hpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-02-25 13:42:22 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-02-27 09:03:30 +0100
commit461312b57d3b49f92861d2c6c5e8a6b13ffa839b (patch)
treec642cd0d3379e6886d1b3847d38661e249e75d58 /test/buildtool/execution_api/common/api_test.hpp
parenteccc7dcfb22fb9c6c42bbcd5566cd044acd1a2f3 (diff)
downloadjustbuild-461312b57d3b49f92861d2c6c5e8a6b13ffa839b.tar.gz
ArtifactBlob: Use static function for construction
Diffstat (limited to 'test/buildtool/execution_api/common/api_test.hpp')
-rw-r--r--test/buildtool/execution_api/common/api_test.hpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/test/buildtool/execution_api/common/api_test.hpp b/test/buildtool/execution_api/common/api_test.hpp
index 8836181d..f8981434 100644
--- a/test/buildtool/execution_api/common/api_test.hpp
+++ b/test/buildtool/execution_api/common/api_test.hpp
@@ -241,12 +241,13 @@ using ExecProps = std::map<std::string, std::string>;
HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
- auto test_digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
- hash_function, test_content);
+ auto const test_blob =
+ ArtifactBlob::FromMemory(hash_function, ObjectType::File, test_content);
+ REQUIRE(test_blob.has_value());
- auto input_artifact_opt =
- ArtifactDescription::CreateKnown(test_digest, ObjectType::File)
- .ToArtifact();
+ auto input_artifact_opt = ArtifactDescription::CreateKnown(
+ test_blob->GetDigest(), ObjectType::File)
+ .ToArtifact();
auto input_artifact =
DependencyGraph::ArtifactNode{std::move(input_artifact_opt)};
@@ -254,8 +255,7 @@ using ExecProps = std::map<std::string, std::string>;
std::string output_path{"output_file"};
auto api = api_factory();
- CHECK(api->Upload(
- {ArtifactBlob{test_digest, test_content, /*is_exec=*/false}}, false));
+ CHECK(api->Upload({*test_blob}, false));
auto action =
api->CreateAction(*api->UploadTree({{input_path, &input_artifact}}),
@@ -277,7 +277,8 @@ using ExecProps = std::map<std::string, std::string>;
auto const artifacts = response->Artifacts();
REQUIRE(artifacts.has_value());
REQUIRE(artifacts.value()->contains(output_path));
- CHECK(artifacts.value()->at(output_path).digest == test_digest);
+ CHECK(artifacts.value()->at(output_path).digest ==
+ test_blob->GetDigest());
if (is_hermetic) {
CHECK(not response->IsCached());
@@ -291,7 +292,8 @@ using ExecProps = std::map<std::string, std::string>;
auto const artifacts = response->Artifacts();
REQUIRE(artifacts.has_value());
REQUIRE(artifacts.value()->contains(output_path));
- CHECK(artifacts.value()->at(output_path).digest == test_digest);
+ CHECK(artifacts.value()->at(output_path).digest ==
+ test_blob->GetDigest());
CHECK(response->IsCached());
}
}
@@ -308,7 +310,8 @@ using ExecProps = std::map<std::string, std::string>;
auto const artifacts = response->Artifacts();
REQUIRE(artifacts.has_value());
REQUIRE(artifacts.value()->contains(output_path));
- CHECK(artifacts.value()->at(output_path).digest == test_digest);
+ CHECK(artifacts.value()->at(output_path).digest ==
+ test_blob->GetDigest());
CHECK(not response->IsCached());
SECTION("Rerun execution to verify caching") {
@@ -320,7 +323,8 @@ using ExecProps = std::map<std::string, std::string>;
auto const artifacts = response->Artifacts();
REQUIRE(artifacts.has_value());
REQUIRE(artifacts.value()->contains(output_path));
- CHECK(artifacts.value()->at(output_path).digest == test_digest);
+ CHECK(artifacts.value()->at(output_path).digest ==
+ test_blob->GetDigest());
CHECK(not response->IsCached());
}
}