From c61aefa2e3fc6ffcffb8548f8df404b66d4d3647 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 24 Jan 2022 19:39:51 +0100 Subject: [PATCH] Test: Add dotfile test case for path exclusion --- test/testdotfile.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/testdotfile.cpp b/test/testdotfile.cpp index a7da4b1..ac3fea2 100644 --- a/test/testdotfile.cpp +++ b/test/testdotfile.cpp @@ -149,7 +149,6 @@ TEST_CASE(PullDotfiles) createTestDotfiles(homeFileNames, homeFileContents); createTestDotfiles(fileNames, workingDirectoryFileContents); - Dotfile::the().setSystemDirectories({ "/etc" }); Dotfile::the().pull(fileNames); for (size_t i = 0; i < fileNames.size(); ++i) { @@ -197,6 +196,32 @@ TEST_CASE(PushDotfiles) removeTestDotfiles(fileNames); } +TEST_CASE(PushDotfilesWithExcludePath) +{ + std::vector fileNames = { + "__test-file-1", + "__subdir/__test-file-2", + "__subdir/__test-file-3", + "__another-subdir/__test-file-4.test", + }; + + createTestDotfiles(fileNames, { "", "", "", "" }); + + Dotfile::the().setExcludePaths({ + { Dotfile::ExcludeType::File, "__test-file-1" }, + { Dotfile::ExcludeType::Directory, "__subdir" }, + { Dotfile::ExcludeType::EndsWith, ".test" }, + }); + Dotfile::the().push(fileNames); + Dotfile::the().setExcludePaths({}); + + for (const auto& file : fileNames) { + EXPECT(!std::filesystem::exists(homeDirectory + '/' + file)); + } + + removeTestDotfiles(fileNames); +} + TEST_CASE(AddSystemDotfiles) { VERIFY(geteuid() == 0);