Skip to content

Commit

Permalink
👷 gucc: replace all ofstream with helper function in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vnepogodin committed Aug 9, 2024
1 parent ce3da4a commit 3e09d7c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 20 deletions.
1 change: 0 additions & 1 deletion gucc/tests/unit-initcpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "gucc/logger.hpp"

#include <filesystem>
#include <fstream>
#include <string>
#include <string_view>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion gucc/tests/unit-locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "gucc/logger.hpp"

#include <filesystem>
#include <fstream>
#include <ranges>
#include <string_view>

Expand Down
18 changes: 3 additions & 15 deletions gucc/tests/unit-mtab.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "doctest_compatibility.h"

#include "gucc/file_utils.hpp"
#include "gucc/mtab.hpp"

#include <filesystem>
#include <fstream>
#include <string_view>

#include <fmt/core.h>
Expand Down Expand Up @@ -121,13 +121,7 @@ TEST_CASE("mtab test")
SECTION("live iso system")
{
static constexpr std::string_view filename{"/tmp/mtab.conf"};
// Open mtab file for writing.
std::ofstream mtab_file{filename.data()};
REQUIRE(mtab_file.is_open());

// Setup mtab file.
mtab_file << MTAB_LIVE_ISO_TEST;
mtab_file.close();
REQUIRE(file_utils::create_file_for_overwrite(filename, MTAB_LIVE_ISO_TEST));

const auto& mtab_entries = gucc::mtab::parse_mtab("/tmp/calamares-root-q_z5rdlx"sv, filename);
REQUIRE(mtab_entries.has_value());
Expand Down Expand Up @@ -170,13 +164,7 @@ TEST_CASE("mtab test")
SECTION("empty file")
{
static constexpr std::string_view filename{"/tmp/mtab.conf"};
// Open mtab file for writing.
std::ofstream mtab_file{filename.data()};
REQUIRE(mtab_file.is_open());

// Setup mtab file.
mtab_file << "";
mtab_file.close();
REQUIRE(file_utils::create_file_for_overwrite(filename, ""));

const auto& mtab_entries = gucc::mtab::parse_mtab("/tmp/calamares-root-q_z5rdlx"sv, filename);
REQUIRE(!mtab_entries.has_value());
Expand Down
1 change: 0 additions & 1 deletion gucc/tests/unit-package_profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "gucc/package_profiles.hpp"

#include <filesystem>
#include <fstream>
#include <string_view>

#include <spdlog/sinks/callback_sink.h>
Expand Down
1 change: 0 additions & 1 deletion gucc/tests/unit-pacmanconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "gucc/pacmanconf_repo.hpp"

#include <filesystem>
#include <fstream>
#include <string>
#include <string_view>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion gucc/tests/unit-refind_extra_kern_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "gucc/logger.hpp"

#include <filesystem>
#include <fstream>
#include <ranges>
#include <string_view>

Expand Down

0 comments on commit 3e09d7c

Please sign in to comment.