diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-10-22 23:25:14 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2022-11-12 20:27:13 +0100 |
commit | e048bce13ea4bd56ef96ba7a1a4699142d09600a (patch) | |
tree | e7d21af731edf70e139b2bef9ac1fa81246cfd2f /tests/FileSystem_test.cpp | |
parent | ddfb449b28fb24f1c3e4ed3802ee4415206f96f1 (diff) | |
download | PrismLauncher-e048bce13ea4bd56ef96ba7a1a4699142d09600a.tar.gz PrismLauncher-e048bce13ea4bd56ef96ba7a1a4699142d09600a.tar.bz2 PrismLauncher-e048bce13ea4bd56ef96ba7a1a4699142d09600a.zip |
refactor: allow copy operation with whitelist
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'tests/FileSystem_test.cpp')
-rw-r--r-- | tests/FileSystem_test.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index 21270f6f..3a5c38d0 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -126,7 +126,7 @@ slots: qDebug() << tempDir.path(); qDebug() << target_dir.path(); FS::copy c(folder, target_dir.path()); - c.blacklist(new RegexpMatcher("[.]?mcmeta")); + c.matcher(new RegexpMatcher("[.]?mcmeta")); c(); for(auto entry: target_dir.entryList()) @@ -147,6 +147,41 @@ slots: f(); } + void test_copy_with_whitelist() + { + QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); + auto f = [&folder]() + { + QTemporaryDir tempDir; + tempDir.setAutoRemove(true); + qDebug() << "From:" << folder << "To:" << tempDir.path(); + + QDir target_dir(FS::PathCombine(tempDir.path(), "test_folder")); + qDebug() << tempDir.path(); + qDebug() << target_dir.path(); + FS::copy c(folder, target_dir.path()); + c.matcher(new RegexpMatcher("[.]?mcmeta")); + c.whitelist(true); + c(); + + for(auto entry: target_dir.entryList()) + { + qDebug() << entry; + } + QVERIFY(target_dir.entryList().contains("pack.mcmeta")); + QVERIFY(!target_dir.entryList().contains("assets")); + }; + + // first try variant without trailing / + QVERIFY(!folder.endsWith('/')); + f(); + + // then variant with trailing / + folder.append('/'); + QVERIFY(folder.endsWith('/')); + f(); + } + void test_copy_with_dot_hidden() { QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); |