/* * Mirai. Copyright (C) 2024 Vyn * This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only) * The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt */ #include "core/BaseFileSource.h" #include "core/Mirai.h" #include "core/StdFileSource.h" #include "core/TaskItem.h" #include "core/TodoMd.h" #include #include TEST_CASE("Saving data") { SECTION("Saving using file resource") { { mirai::Mirai mirai; auto fileResource = std::make_unique( mirai::BaseFileSourceConstructor{.name = "Testing", .path = "testing.md"} ); mirai.loadResource(std::move(fileResource)); auto task = mirai::TodoMdFormat::stringToTask( "- [X] 08:00-10:00 > This is a test -- #mirai", "2024-04-19" ); mirai.getResources()[0]->addTask(task); mirai.save(); } { mirai::Mirai mirai; auto fileResource = std::make_unique( mirai::BaseFileSourceConstructor{.name = "Testing", .path = "testing.md"} ); mirai.loadResource(std::move(fileResource)); const auto &resources = mirai.getResources(); REQUIRE(resources.size() == 1); REQUIRE(resources[0]->getName() == "Testing"); REQUIRE(resources[0]->getTasks().size() == 1); REQUIRE(resources[0]->getTasks().at(0)->getText() == "This is a test"); REQUIRE(resources[0]->getTasks().at(0)->getDate() == "2024-04-19"); } } }