diff --git a/.gitignore b/.gitignore index aa3ea71..e247b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ vcpkg_installed/ # test output & cache Testing/ .cache/ + +#system metadata +*.DS_Store diff --git a/src/config_manager.cpp b/src/config_manager.cpp index edf99aa..4bd3896 100644 --- a/src/config_manager.cpp +++ b/src/config_manager.cpp @@ -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::Err(FWError::make( ErrorCode::TASK_ALREADY_EXISTS, "Error: task already exists, use update_task to update it")); @@ -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; @@ -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::Ok(); diff --git a/tests/unit/test_config_manager.cpp b/tests/unit/test_config_manager.cpp index 478c9eb..1f0a115 100644 --- a/tests/unit/test_config_manager.cpp +++ b/tests/unit/test_config_manager.cpp @@ -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{"ls"}, vector{"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{"ls"}, vector{"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{"ls"}, vector{"cd, ls"}, {"*.o"}, {".git"}, true, true); }