Skip to content

Commit

Permalink
Clean up before each test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryouze committed Sep 17, 2024
1 parent e9e18f3 commit 7aff754
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ int test_html::save_load()
// Get path to the resources directory
const auto temp_file = (pathmaster::get_resources_directory(TEST_EXECUTABLE_NAME) / "test_channels.html").string();

// Clean up before the tests
const auto temp_dir = std::filesystem::path(temp_file).parent_path();
if (!std::filesystem::exists(temp_dir)) {
throw std::runtime_error("Directory wasn't created: " + temp_dir.string());
}
std::filesystem::remove_all(temp_dir);
std::filesystem::create_directories(temp_dir);

// Create a dummy vector of channels ("core::html::load" will sort them alphabetically by name, so the order is important!)
const std::vector<core::html::Channel> channels = {
core::html::Channel("Engineering Explained", "https://www.youtube.com/@EngineeringExplained", "Car Engineering"),
Expand Down Expand Up @@ -266,6 +274,14 @@ int test_disk::save_load()
// Get path to the resources directory
const auto temp_file = (pathmaster::get_resources_directory(TEST_EXECUTABLE_NAME) / "test_table.html").string();

// Clean up before the tests
const auto temp_dir = std::filesystem::path(temp_file).parent_path();
if (!std::filesystem::exists(temp_dir)) {
throw std::runtime_error("Directory wasn't created: " + temp_dir.string());
}
std::filesystem::remove_all(temp_dir);
std::filesystem::create_directories(temp_dir);

// Create a table at the temporary file path
modules::disk::Table table(temp_file);
fmt::print("modules::disk::Table() passed: created table at {}.\n", temp_file);
Expand Down

0 comments on commit 7aff754

Please sign in to comment.