diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-26 10:16:26 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-27 09:03:30 +0100 |
commit | 92b7c00ab851156ed89f9cbb9d05bb787362a209 (patch) | |
tree | 154e03f3ecaf0993e0b6720b83c715e1094e1df3 /test/buildtool | |
parent | a9f1d97f3b288df2b490665ae88b62407ef97ca7 (diff) | |
download | justbuild-92b7c00ab851156ed89f9cbb9d05bb787362a209.tar.gz |
BazelNetwork: Adapt the test that reads objects of unknown size
Diffstat (limited to 'test/buildtool')
-rw-r--r-- | test/buildtool/execution_api/bazel/bazel_network.test.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/test/buildtool/execution_api/bazel/bazel_network.test.cpp b/test/buildtool/execution_api/bazel/bazel_network.test.cpp index fd812287..b902473b 100644 --- a/test/buildtool/execution_api/bazel/bazel_network.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_network.test.cpp @@ -135,24 +135,28 @@ TEST_CASE("Bazel network: read blobs with unknown size", "[execution_api]") { std::string content_foo("foo"); std::string content_bar(kLargeSize, 'x'); // single larger blob - auto const info_foo = - HashInfo::HashData(hash_function, content_foo, /*is_tree=*/false); - auto const info_bar = - HashInfo::HashData(hash_function, content_bar, /*is_tree=*/false); - - ArtifactBlob foo{ArtifactDigest(info_foo, /*size_unknown=*/0), - content_foo, - /*is_exec=*/false}; - ArtifactBlob bar{ArtifactDigest(info_bar, /*size_unknown=*/0), - content_bar, - /*is_exec=*/false}; + // Create and upload blobs: + { + auto const foo_blob = ArtifactBlob::FromMemory( + hash_function, ObjectType::File, content_foo); + REQUIRE(foo_blob.has_value()); + auto const bar_blob = ArtifactBlob::FromMemory( + hash_function, ObjectType::File, content_bar); + REQUIRE(bar_blob.has_value()); + REQUIRE(network.UploadBlobs({*foo_blob, *bar_blob})); + } - // Upload blobs - REQUIRE(network.UploadBlobs({foo, bar})); + // Create digests of unknown size: + auto const foo_digest = ArtifactDigest{ + HashInfo::HashData(hash_function, content_foo, /*is_tree=*/false), + /*size_unknown=*/0}; + auto const bar_digest = ArtifactDigest{ + HashInfo::HashData(hash_function, content_bar, /*is_tree=*/false), + /*size_unknown=*/0}; // Read blobs auto reader = network.CreateReader(); - std::vector<ArtifactDigest> to_read{foo.GetDigest(), bar.GetDigest()}; + std::vector<ArtifactDigest> to_read{foo_digest, bar_digest}; std::vector<ArtifactBlob> blobs{}; for (auto next : reader.ReadIncrementally(&to_read)) { blobs.insert(blobs.end(), next.begin(), next.end()); |