From 66df7f4956c6fe1823eb43d31c3cbac7d8716125 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 24 Jan 2024 17:09:01 +0100 Subject: just-mr: Failure in serve api root tree requests should be fatal The requests to retrieve the tree of a commit, archive, or distdir also set up those trees in a way that the serve endpoint can later build against them, besides allowing just-mr to set up roots locally. Therefore, if the witnessing entity (Git commit, content blob, or distdir, respectively) is known to the serve endpoint, then failing to set up the root tree there should result in a failure also of the just-mr setup on the client side. --- .../serve_api/source_tree_client.test.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'test/buildtool/serve_api/source_tree_client.test.cpp') diff --git a/test/buildtool/serve_api/source_tree_client.test.cpp b/test/buildtool/serve_api/source_tree_client.test.cpp index 8c1e3b30..bc8bfad1 100644 --- a/test/buildtool/serve_api/source_tree_client.test.cpp +++ b/test/buildtool/serve_api/source_tree_client.test.cpp @@ -36,33 +36,35 @@ TEST_CASE("Serve service client: tree-of-commit request", "[serve_api]") { SECTION("Commit in bare checkout") { auto root_id = st_client.ServeCommitTree(kRootCommit, ".", false); - REQUIRE(root_id); - CHECK(root_id.value() == kRootId); + REQUIRE(std::holds_alternative(root_id)); + CHECK(std::get(root_id) == kRootId); auto baz_id = st_client.ServeCommitTree(kRootCommit, "baz", false); - REQUIRE(baz_id); - CHECK(baz_id.value() == kBazId); + REQUIRE(std::holds_alternative(baz_id)); + CHECK(std::get(baz_id) == kBazId); } SECTION("Commit in non-bare checkout") { auto root_id = st_client.ServeCommitTree(kRootSymCommit, ".", false); - REQUIRE(root_id); - CHECK(root_id.value() == kRootSymId); + REQUIRE(std::holds_alternative(root_id)); + CHECK(std::get(root_id) == kRootSymId); auto baz_id = st_client.ServeCommitTree(kRootSymCommit, "baz", false); - REQUIRE(baz_id); - CHECK(baz_id.value() == kBazSymId); + REQUIRE(std::holds_alternative(baz_id)); + CHECK(std::get(baz_id) == kBazSymId); } SECTION("Subdir not found") { auto root_id = st_client.ServeCommitTree(kRootCommit, "does_not_exist", false); - CHECK_FALSE(root_id); + REQUIRE(std::holds_alternative(root_id)); + CHECK(std::get(root_id)); // fatal failure } SECTION("Commit not known") { auto root_id = st_client.ServeCommitTree( "0123456789abcdef0123456789abcdef01234567", ".", false); - CHECK_FALSE(root_id); + REQUIRE(std::holds_alternative(root_id)); + CHECK_FALSE(std::get(root_id)); // non-fatal failure } } -- cgit v1.2.3