Completing task building.
This commit is contained in:
@@ -13,8 +13,8 @@ TEST_CASE("Parameter Parsing", "[utilities_parse_parameters]") {
|
||||
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name"})"};
|
||||
auto params = daggy::parseParameters(testParams);
|
||||
REQUIRE(params.size() == 2);
|
||||
REQUIRE(std::holds_alternative<std::vector<std::string>>(params["DATE"]));
|
||||
REQUIRE(std::holds_alternative<std::string>(params["SOURCE"]));
|
||||
REQUIRE(std::holds_alternative<std::vector<std::string>>(params["{{DATE}}"]));
|
||||
REQUIRE(std::holds_alternative<std::string>(params["{{SOURCE}}"]));
|
||||
}
|
||||
SECTION("Invalid JSON") {
|
||||
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name")"};
|
||||
@@ -28,4 +28,52 @@ TEST_CASE("Parameter Parsing", "[utilities_parse_parameters]") {
|
||||
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": {"name": "kevin"}})"};
|
||||
REQUIRE_THROWS(daggy::parseParameters(testParams));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Parameter Expansion", "[utilities_parameter_expansion]") {
|
||||
SECTION("Basic Parse") {
|
||||
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name", "TYPE": ["a", "b", "c"]})"};
|
||||
auto params = daggy::parseParameters(testParams);
|
||||
std::vector<std::string> cmd{"/usr/bin/echo", "{{DATE}}", "{{SOURCE}}", "{{TYPE}}"};
|
||||
auto allCmds = daggy::expandCommands(cmd, params);
|
||||
|
||||
REQUIRE(allCmds.size() == 6);
|
||||
}
|
||||
|
||||
SECTION("Skip over unused parameters") {
|
||||
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name", "TYPE": ["a", "b", "c"]})"};
|
||||
auto params = daggy::parseParameters(testParams);
|
||||
std::vector<std::string> cmd{"/usr/bin/echo", "{{DATE}}", "{{SOURCE}}"};
|
||||
auto allCmds = daggy::expandCommands(cmd, params);
|
||||
|
||||
// TYPE isn't used, so it's just |DATE| * |SOURCE|
|
||||
REQUIRE(allCmds.size() == 2);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Building Tasks", "[utilities_build_tasks]") {
|
||||
SECTION("Build with no expansion") {
|
||||
std::string testTasks = R"([{"name": "A", "command": ["/bin/echo", "A"], "children": ["C"]}, {"name": "B", "command": ["/bin/echo", "B"], "children": ["C"]},{"name": "C", "command": ["/bin/echo", "C"]}])";
|
||||
auto tasks = daggy::buildTasks(testTasks);
|
||||
REQUIRE(tasks.size() == 3);
|
||||
}
|
||||
|
||||
SECTION("Build with expansion") {
|
||||
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ], "SOURCE": "name"})"};
|
||||
auto params = daggy::parseParameters(testParams);
|
||||
std::string testTasks = R"([{"name": "A", "command": ["/bin/echo", "A"], "children": ["B"]}, {"name": "B", "command": ["/bin/echo", "B", "{{SOURCE}}", "{{DATE}}"], "children": ["C"]},{"name": "C", "command": ["/bin/echo", "C"]}])";
|
||||
auto tasks = daggy::buildTasks(testTasks, params);
|
||||
|
||||
/*
|
||||
for (const auto & task : tasks) {
|
||||
std::cout << task.name << ": ";
|
||||
for (const auto & part : task.children) {
|
||||
std::cout << part << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
*/
|
||||
REQUIRE(tasks.size() == 4);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user