diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-25 11:46:51 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-27 09:03:30 +0100 |
commit | b3c6d3572784575811ff130d859e92b799e77bb3 (patch) | |
tree | dc37456d28fa9e464bdd50eb3218a6917c73e4be /test/buildtool | |
parent | 9a987188a38cc18f6a485bd5def16aded10fe1f6 (diff) | |
download | justbuild-b3c6d3572784575811ff130d859e92b799e77bb3.tar.gz |
ArtifactBlob: Check access to the content
Diffstat (limited to 'test/buildtool')
4 files changed, 22 insertions, 4 deletions
diff --git a/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp b/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp index 488483ae..031da8f0 100644 --- a/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp @@ -79,6 +79,8 @@ TEST_CASE("Bazel internals: CAS Client", "[execution_api]") { auto blobs = cas_client.BatchReadBlobs(instance_name, {digest}); REQUIRE(blobs.size() == 1); CHECK(blobs.begin()->GetDigest() == digest); - CHECK(*blobs.begin()->ReadContent() == content); + auto const read_content = blobs.begin()->ReadContent(); + CHECK(read_content != nullptr); + CHECK(*read_content == content); } } diff --git a/test/buildtool/execution_api/bazel/bazel_network.test.cpp b/test/buildtool/execution_api/bazel/bazel_network.test.cpp index 1bc6c0ac..3cb0ef35 100644 --- a/test/buildtool/execution_api/bazel/bazel_network.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_network.test.cpp @@ -99,6 +99,9 @@ TEST_CASE("Bazel network: write/read blobs", "[execution_api]") { // Check order maintained REQUIRE(blobs.size() == 5); + for (auto const& blob : blobs) { + REQUIRE(blob.ReadContent() != nullptr); + } CHECK(*blobs[0].ReadContent() == content_foo); CHECK(*blobs[1].ReadContent() == content_bar); CHECK(*blobs[2].ReadContent() == content_baz); @@ -160,6 +163,9 @@ TEST_CASE("Bazel network: read blobs with unknown size", "[execution_api]") { // Check order maintained REQUIRE(blobs.size() == 2); + for (auto const& blob : blobs) { + REQUIRE(blob.ReadContent() != nullptr); + } CHECK(*blobs[0].ReadContent() == content_foo); CHECK(*blobs[1].ReadContent() == content_bar); } diff --git a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp index 4676a5c6..991dcf72 100644 --- a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp @@ -61,7 +61,10 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { auto const downloaded_blob = stream.Read(instance_name, digest); REQUIRE(downloaded_blob.has_value()); - CHECK(*downloaded_blob->ReadContent() == content); + + auto const downloaded_content = downloaded_blob->ReadContent(); + REQUIRE(downloaded_content != nullptr); + CHECK(*downloaded_content == content); } SECTION("Small blob with wrong digest") { @@ -97,7 +100,10 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { SECTION("Download large blob") { auto const downloaded_blob = stream.Read(instance_name, digest); REQUIRE(downloaded_blob.has_value()); - CHECK(*downloaded_blob->ReadContent() == content); + + auto const downloaded_content = downloaded_blob->ReadContent(); + REQUIRE(downloaded_content != nullptr); + CHECK(*downloaded_content == content); } SECTION("Incrementally download large blob") { diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp index 36b407c7..9af21383 100644 --- a/test/buildtool/execution_engine/executor/executor.test.cpp +++ b/test/buildtool/execution_engine/executor/executor.test.cpp @@ -226,7 +226,11 @@ class TestApi : public IExecutionApi { return std::all_of( blobs.begin(), blobs.end(), [this](auto const& blob) { // for local artifacts - auto it1 = config_.artifacts.find(*blob.ReadContent()); + auto const content = blob.ReadContent(); + if (content == nullptr) { + return false; + } + auto it1 = config_.artifacts.find(*content); if (it1 != config_.artifacts.end() and it1->second.uploads) { return true; } |