Skip to content

Commit

Permalink
Unit tests: Unification, use name "temp_dir" for all languages
Browse files Browse the repository at this point in the history
  • Loading branch information
jrohel authored and kontura committed Dec 10, 2024
1 parent 59a0a83 commit fd199fe
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/dnf5-plugins/copr_plugin/CoprRepoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ std::string repo_to_string(const dnf5::CoprRepo & repo) {
}

void CoprRepoTest::prepare_env() {
installroot = temp->get_path() / "installroot";
installroot = temp_dir->get_path() / "installroot";
std::filesystem::create_directory(installroot);
confdir = installroot / "etc";
std::filesystem::create_directory(confdir);
Expand Down
2 changes: 1 addition & 1 deletion test/libdnf5/comps/test_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void CompsGroupTest::test_serialize() {
q_standard.filter_groupid("standard");
auto standard = q_standard.get();

auto serialize_path = temp->get_path() / "serialized-standard.xml";
auto serialize_path = temp_dir->get_path() / "serialized-standard.xml";
standard.serialize(serialize_path);

std::string actual = libdnf5::utils::fs::File(serialize_path, "r").read();
Expand Down
2 changes: 1 addition & 1 deletion test/libdnf5/repo/test_temp_files_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace libdnf5::repo;

void TempFilesMemoryTest::setUp() {
BaseTestCase::setUp();
parent_dir_path = temp->get_path();
parent_dir_path = temp_dir->get_path();
full_path = parent_dir_path / TempFilesMemory::MEMORY_FILENAME;
}

Expand Down
6 changes: 3 additions & 3 deletions test/perl5/libdnf5/BaseTestCase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ sub new {

$self->{base} = new libdnf5::base::Base();

$self->{tmpdir} = tempdir("libdnf5_perl5_unittest.XXXX", TMPDIR => 1, CLEANUP => 1);
$self->{temp_dir} = tempdir("libdnf5_perl5_unittest.XXXX", TMPDIR => 1, CLEANUP => 1);

my $config = $self->{base}->get_config();
$config->get_installroot_option()->set($libdnf5::conf::Option::Priority_RUNTIME, $self->{tmpdir}."/installroot");
$config->get_cachedir_option()->set($libdnf5::conf::Option::Priority_RUNTIME, $self->{tmpdir}."/cache");
$config->get_installroot_option()->set($libdnf5::conf::Option::Priority_RUNTIME, $self->{temp_dir}."/installroot");
$config->get_cachedir_option()->set($libdnf5::conf::Option::Priority_RUNTIME, $self->{temp_dir}."/cache");
$config->get_optional_metadata_types_option()->set($libdnf5::conf::Option::Priority_RUNTIME, $libdnf5::conf::OPTIONAL_METADATA_TYPES);

# Prevent loading plugins from host
Expand Down
8 changes: 4 additions & 4 deletions test/shared/base_test_case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ void BaseTestCase::setUp() {

// TODO we could use get_preconfigured_base() for this now, but that would
// need changing the `base` member to a unique_ptr
temp = std::make_unique<libdnf5::utils::fs::TempDir>("libdnf5_unittest");
std::filesystem::create_directory(temp->get_path() / "installroot");
temp_dir = std::make_unique<libdnf5::utils::fs::TempDir>("libdnf5_unittest");
std::filesystem::create_directory(temp_dir->get_path() / "installroot");

base.get_config().get_installroot_option().set(temp->get_path() / "installroot");
base.get_config().get_cachedir_option().set(temp->get_path() / "cache");
base.get_config().get_installroot_option().set(temp_dir->get_path() / "installroot");
base.get_config().get_cachedir_option().set(temp_dir->get_path() / "cache");
base.get_config().get_optional_metadata_types_option().set(libdnf5::OPTIONAL_METADATA_TYPES);

// Prevent loading libdnf5 plugins
Expand Down
8 changes: 4 additions & 4 deletions test/shared/test_case_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ void TestCaseFixture::tearDown() {
}

std::unique_ptr<libdnf5::Base> TestCaseFixture::get_preconfigured_base() {
temp = std::make_unique<libdnf5::utils::fs::TempDir>("libdnf5_unittest");
std::filesystem::create_directory(temp->get_path() / "installroot");
temp_dir = std::make_unique<libdnf5::utils::fs::TempDir>("libdnf5_unittest");
std::filesystem::create_directory(temp_dir->get_path() / "installroot");

std::unique_ptr<libdnf5::Base> base(new libdnf5::Base());
base->get_config().get_installroot_option().set(temp->get_path() / "installroot");
base->get_config().get_cachedir_option().set(temp->get_path() / "cache");
base->get_config().get_installroot_option().set(temp_dir->get_path() / "installroot");
base->get_config().get_cachedir_option().set(temp_dir->get_path() / "cache");

// Prevent loading libdnf5 plugins
base->get_config().get_plugins_option().set(false);
Expand Down
2 changes: 1 addition & 1 deletion test/shared/test_case_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestCaseFixture : public CppUnit::TestCase {
std::unique_ptr<libdnf5::Base> get_preconfigured_base();

// Only gets created if get_preconfigured_base() is called
std::unique_ptr<libdnf5::utils::fs::TempDir> temp;
std::unique_ptr<libdnf5::utils::fs::TempDir> temp_dir;
};


Expand Down

0 comments on commit fd199fe

Please sign in to comment.