mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 09:23:18 +00:00
Change 'File' concept to a 'Resource' abstract concept
This commit is contained in:
parent
7eb54cddce
commit
ca34562a1c
23 changed files with 447 additions and 351 deletions
|
@ -4,8 +4,6 @@
|
|||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
// TODO this is just a quick setup for later
|
||||
|
||||
#include "core/Mirai.h"
|
||||
#include "core/TaskItem.h"
|
||||
#include "core/TodoMd.h"
|
48
tests/saving.cpp
Normal file
48
tests/saving.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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/BaseFileResource.h"
|
||||
#include "core/Mirai.h"
|
||||
#include "core/StdFileResource.h"
|
||||
#include "core/TaskItem.h"
|
||||
#include "core/TodoMd.h"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <memory>
|
||||
|
||||
TEST_CASE("Saving data")
|
||||
{
|
||||
SECTION("Saving using file resource")
|
||||
{
|
||||
{
|
||||
mirai::Mirai mirai;
|
||||
auto fileResource = std::make_unique<mirai::StdFileResource>(
|
||||
mirai::BaseFileResourceConstructor{.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::StdFileResource>(
|
||||
mirai::BaseFileResourceConstructor{.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");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue