Skip to content

Commit

Permalink
Test for adding an empty list to memory file
Browse files Browse the repository at this point in the history
Although this scenario is not expected, make sure it is not crashing.
  • Loading branch information
jan-kolarik committed Nov 24, 2023
1 parent d31e368 commit 5102046
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/libdnf5/repo/test_temp_files_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ void TempFilesMemoryTest::test_add_files_when_empty_storage() {
CPPUNIT_ASSERT_EQUAL(new_paths, memory.get_files());
}

void TempFilesMemoryTest::test_add_no_files_when_empty_storage() {
TempFilesMemory memory(base.get_weak_ptr(), parent_dir_path);
CPPUNIT_ASSERT(memory.get_files().empty());

std::vector<std::string> empty_paths = {};
memory.add_files(empty_paths);
CPPUNIT_ASSERT(memory.get_files().empty());
}

void TempFilesMemoryTest::test_add_files_when_existing_storage() {
std::vector<std::string> new_paths = {"path3", "path4"};
libdnf5::utils::fs::File(full_path, "w")
Expand Down
2 changes: 2 additions & 0 deletions test/libdnf5/repo/test_temp_files_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class TempFilesMemoryTest : public BaseTestCase {
CPPUNIT_TEST(test_get_files_throws_exception_when_invalid_format);
CPPUNIT_TEST(test_get_files_returns_stored_values);
CPPUNIT_TEST(test_add_files_when_empty_storage);
CPPUNIT_TEST(test_add_no_files_when_empty_storage);
CPPUNIT_TEST(test_add_files_when_existing_storage);
CPPUNIT_TEST(test_add_files_deduplicates_and_sorts_data);
CPPUNIT_TEST(test_clear_deletes_storage_content);
Expand All @@ -48,6 +49,7 @@ class TempFilesMemoryTest : public BaseTestCase {
void test_get_files_throws_exception_when_invalid_format();
void test_get_files_returns_stored_values();
void test_add_files_when_empty_storage();
void test_add_no_files_when_empty_storage();
void test_add_files_when_existing_storage();
void test_add_files_deduplicates_and_sorts_data();
void test_clear_deletes_storage_content();
Expand Down

0 comments on commit 5102046

Please sign in to comment.