This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "mission/mission_store.hpp"
|
||||
#include "storage/database.hpp"
|
||||
#include "util/file_util.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -18,21 +20,27 @@ protected:
|
||||
/ ("lm_test_" + std::to_string(getpid()) + "_"
|
||||
+ std::to_string(seq.fetch_add(1)));
|
||||
std::filesystem::create_directories(dir_);
|
||||
store_path_ = dir_ / "missions.json";
|
||||
std::filesystem::copy_file(std::filesystem::path(TEST_FIXTURE_DIR) / "missions.json",
|
||||
store_path_,
|
||||
std::filesystem::copy_options::overwrite_existing);
|
||||
store_ = std::make_unique<lm::MissionStore>(store_path_);
|
||||
db_ = std::make_unique<lm::Database>(dir_);
|
||||
std::string err;
|
||||
ASSERT_TRUE(db_->init(err)) << err;
|
||||
|
||||
const auto fixture = std::filesystem::path(TEST_FIXTURE_DIR) / "missions.json";
|
||||
const auto raw = lm::FileUtil::readBinary(fixture);
|
||||
auto doc = nlohmann::json::parse(raw);
|
||||
ASSERT_TRUE(db_->setDocument("missions", doc));
|
||||
store_ = std::make_unique<lm::MissionStore>(*db_);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
store_.reset();
|
||||
db_.reset();
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(dir_, ec);
|
||||
}
|
||||
|
||||
std::filesystem::path dir_;
|
||||
std::filesystem::path store_path_;
|
||||
std::unique_ptr<lm::Database> db_;
|
||||
std::unique_ptr<lm::MissionStore> store_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user