44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#include <catch2/catch.hpp>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <thread>
|
|
|
|
#include "daggy/Serialization.hpp"
|
|
#include "daggy/Utilities.hpp"
|
|
#include "daggy/executors/task/NoopTaskExecutor.hpp"
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
TEST_CASE("noop_executor", "[noop_executor]")
|
|
{
|
|
daggy::executors::task::NoopTaskExecutor ex;
|
|
|
|
SECTION("Simple Run")
|
|
{
|
|
daggy::Task task{
|
|
.job{{"command", daggy::executors::task::NoopTaskExecutor::Command{
|
|
"/bin/echo", "abc", "123"}}}};
|
|
|
|
REQUIRE(ex.validateTaskParameters(task.job));
|
|
|
|
auto recFuture = ex.execute(0, "command", task);
|
|
auto rec = recFuture->get();
|
|
|
|
REQUIRE(rec.rc == 0);
|
|
}
|
|
|
|
SECTION("Expansion with environment")
|
|
{
|
|
std::string testParams{R"({"DATE": ["2021-05-06", "2021-05-07" ]})"};
|
|
auto params = daggy::configFromJSON(testParams);
|
|
|
|
std::string taskJSON =
|
|
R"({"B": {"job": {"command": ["/bin/echo", "{{DATE}}"], "environment": [ "TEST={{DATE}}"] }, "children": ["C"]}})";
|
|
auto tasks = daggy::tasksFromJSON(taskJSON);
|
|
|
|
auto result = daggy::expandTaskSet(tasks, ex, params);
|
|
REQUIRE(result.size() == 2);
|
|
}
|
|
}
|