Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ vcpkg_installed/
# test output & cache
Testing/
.cache/

#system metadata
*.DS_Store
10 changes: 5 additions & 5 deletions src/config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace flowhook
for (auto &t : config_obj["tasks"])
{
Task _ts = TRY(convert_json_to_task(t), void);
if (_ts.name == task.name)
if (_ts.id == task.id)
{
return Result<void>::Err(FWError::make(
ErrorCode::TASK_ALREADY_EXISTS, "Error: task already exists, use update_task to update it"));
Expand All @@ -238,8 +238,8 @@ namespace flowhook
{
for (auto it = config_obj["tasks"].begin(); it != config_obj["tasks"].end(); it++)
{
string name = it->at("task_name");
if (name == task.name)
string id = it->at("working_directory");
if (id == task.id)
{
json _json_task = TRY(convert_task_to_json(task), void);
*it = _json_task;
Expand Down Expand Up @@ -277,8 +277,8 @@ namespace flowhook
{
for (auto it = config_obj["tasks"].begin(); it != config_obj["tasks"].end(); it++)
{
string name = it->at("task_name");
if (name == task.name)
string id = it->at("working_directory");
if (id == task.id)
{
config_obj["tasks"].erase(it);
return Result<void>::Ok();
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ UTEST_F_SETUP(ConfigManagerFixture)
fs::create_directories("/tmp/cm_test");
fs::create_directories("/tmp/cm_test2");

utest_fixture->t = new Task("test_task", "/tmp/cm_test", 3, {"ls"},
utest_fixture->t = new Task("/tmp/cm_test", "test_task", 3, {"ls"},
{"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector<string>{"ls"}, vector<string>{"ls"}, {"*.o"}, {".git"}, true, true);

utest_fixture->t2 = new Task("test_task2", "/tmp/cm_test2", 3, {"ls"},
{"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector<string>{"ls"}, vector<string>{"cd, ls"}, {"*.o"}, {".git"}, true, true);

utest_fixture->t3 = new Task("test_task1", "/tmp/cm_test", 3, {"cd", "make"},
utest_fixture->t3 = new Task("/tmp/cm_test", "test_task", 3, {"cd", "make"},
{"/tmp/cm_test_file.txt"}, {"/tmp/cm_test"}, vector<string>{"ls"}, vector<string>{"cd, ls"}, {"*.o"}, {".git"}, true, true);
}

Expand Down
Loading