diff options
Diffstat (limited to 'test/buildtool/common/action_description.test.cpp')
-rw-r--r-- | test/buildtool/common/action_description.test.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/test/buildtool/common/action_description.test.cpp b/test/buildtool/common/action_description.test.cpp index eab2cc48..7d5a72d7 100644 --- a/test/buildtool/common/action_description.test.cpp +++ b/test/buildtool/common/action_description.test.cpp @@ -20,6 +20,14 @@ #include "nlohmann/json.hpp" #include "src/buildtool/common/action.hpp" #include "src/buildtool/common/artifact_description.hpp" +#include "src/buildtool/compatibility/compatibility.hpp" +#include "src/buildtool/crypto/hash_function.hpp" + +[[nodiscard]] static inline auto GetHashType(bool compatible) noexcept + -> HashFunction::Type { + return compatible ? HashFunction::Type::PlainSHA256 + : HashFunction::Type::GitSHA1; +} TEST_CASE("From JSON", "[action_description]") { using path = std::filesystem::path; @@ -37,56 +45,57 @@ TEST_CASE("From JSON", "[action_description]") { desc.Inputs()} .ToJson(); + auto const hash_type = GetHashType(Compatibility::IsCompatible()); SECTION("Parse full action") { - auto description = ActionDescription::FromJson("id", json); + auto description = ActionDescription::FromJson(hash_type, "id", json); REQUIRE(description); CHECK((*description)->ToJson() == json); } SECTION("Parse action without optional input") { json["input"] = nlohmann::json::object(); - CHECK(ActionDescription::FromJson("id", json)); + CHECK(ActionDescription::FromJson(hash_type, "id", json)); json["input"] = nlohmann::json::array(); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); json.erase("input"); - CHECK(ActionDescription::FromJson("id", json)); + CHECK(ActionDescription::FromJson(hash_type, "id", json)); } SECTION("Parse action without optional env") { json["env"] = nlohmann::json::object(); - CHECK(ActionDescription::FromJson("id", json)); + CHECK(ActionDescription::FromJson(hash_type, "id", json)); json["env"] = nlohmann::json::array(); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); json.erase("env"); - CHECK(ActionDescription::FromJson("id", json)); + CHECK(ActionDescription::FromJson(hash_type, "id", json)); } SECTION("Parse action without mandatory outputs") { json["output"] = nlohmann::json::array(); json["output_dirs"] = nlohmann::json::array(); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); json["output"] = nlohmann::json::object(); json["output_dirs"] = nlohmann::json::object(); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); json.erase("output"); json.erase("output_dirs"); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); } SECTION("Parse action without mandatory command") { json["command"] = nlohmann::json::array(); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); json["command"] = nlohmann::json::object(); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); json.erase("command"); - CHECK_FALSE(ActionDescription::FromJson("id", json)); + CHECK_FALSE(ActionDescription::FromJson(hash_type, "id", json)); } } |