diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-25 13:42:22 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-27 09:03:30 +0100 |
commit | 461312b57d3b49f92861d2c6c5e8a6b13ffa839b (patch) | |
tree | c642cd0d3379e6886d1b3847d38661e249e75d58 /test/buildtool/execution_api/bazel/bytestream_client.test.cpp | |
parent | eccc7dcfb22fb9c6c42bbcd5566cd044acd1a2f3 (diff) | |
download | justbuild-461312b57d3b49f92861d2c6c5e8a6b13ffa839b.tar.gz |
ArtifactBlob: Use static function for construction
Diffstat (limited to 'test/buildtool/execution_api/bazel/bytestream_client.test.cpp')
-rw-r--r-- | test/buildtool/execution_api/bazel/bytestream_client.test.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp index 991dcf72..823c317c 100644 --- a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp @@ -30,6 +30,7 @@ #include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/file_system/object_type.hpp" +#include "src/utils/cpp/expected.hpp" #include "test/utils/hermeticity/test_hash_function_type.hpp" #include "test/utils/remote_execution/test_auth_config.hpp" #include "test/utils/remote_execution/test_remote_config.hpp" @@ -53,13 +54,14 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { std::string content("foobar"); // digest of "foobar" - auto digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>( - hash_function, content); + auto const blob = + ArtifactBlob::FromMemory(hash_function, ObjectType::File, content); + REQUIRE(blob.has_value()); - ArtifactBlob const blob{digest, content, /*is_exec=*/false}; - CHECK(stream.Write(instance_name, blob)); + CHECK(stream.Write(instance_name, *blob)); - auto const downloaded_blob = stream.Read(instance_name, digest); + auto const downloaded_blob = + stream.Read(instance_name, blob->GetDigest()); REQUIRE(downloaded_blob.has_value()); auto const downloaded_content = downloaded_blob->ReadContent(); @@ -91,14 +93,15 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { } // digest of "instance_nameinstance_nameinstance_..." - auto digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>( - hash_function, content); - ArtifactBlob const blob{digest, content, /*is_exec=*/false}; + auto const blob = + ArtifactBlob::FromMemory(hash_function, ObjectType::File, content); + REQUIRE(blob.has_value()); - CHECK(stream.Write(instance_name, blob)); + CHECK(stream.Write(instance_name, *blob)); SECTION("Download large blob") { - auto const downloaded_blob = stream.Read(instance_name, digest); + auto const downloaded_blob = + stream.Read(instance_name, blob->GetDigest()); REQUIRE(downloaded_blob.has_value()); auto const downloaded_content = downloaded_blob->ReadContent(); @@ -107,7 +110,8 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { } SECTION("Incrementally download large blob") { - auto reader = stream.IncrementalRead(instance_name, digest); + auto reader = + stream.IncrementalRead(instance_name, blob->GetDigest()); std::string data{}; auto chunk = reader.Next(); |