29 lines
1.1 KiB
C++
29 lines
1.1 KiB
C++
#include <iostream>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
#include "catch.hpp"
|
|
|
|
#include "daggy/Utilities.hpp"
|
|
#include "daggy/Serialization.hpp"
|
|
|
|
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::parametersFromJSON(testParams);
|
|
std::vector<std::string> cmd{"/usr/bin/echo", "{{DATE}}", "{{SOURCE}}", "{{TYPE}}"};
|
|
auto allCommands = daggy::expandCommands(cmd, params);
|
|
|
|
REQUIRE(allCommands.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::parametersFromJSON(testParams);
|
|
std::vector<std::string> cmd{"/usr/bin/echo", "{{DATE}}", "{{SOURCE}}"};
|
|
auto allCommands = daggy::expandCommands(cmd, params);
|
|
|
|
// TYPE isn't used, so it's just |DATE| * |SOURCE|
|
|
REQUIRE(allCommands.size() == 2);
|
|
}
|
|
} |