diff options
author | flow <flowlnlnln@gmail.com> | 2022-09-12 13:12:55 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-09-12 13:12:55 -0300 |
commit | 931d6c280a877cefddcc93660aba0c1c0c014366 (patch) | |
tree | 83bbd97e8809879e3db1822cb31bd8881c076e17 /tests | |
parent | ee0fb2d0e00bba8c000a277d5f7199ae46a095df (diff) | |
download | PrismLauncher-931d6c280a877cefddcc93660aba0c1c0c014366.tar.gz PrismLauncher-931d6c280a877cefddcc93660aba0c1c0c014366.tar.bz2 PrismLauncher-931d6c280a877cefddcc93660aba0c1c0c014366.zip |
chore(tests): add test for copy operation with blacklist
I almost :skull: because no tests used this x.x
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/FileSystem_test.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index 6df13e80..4efb90ac 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -4,6 +4,8 @@ #include <FileSystem.h> +#include <pathmatcher/RegexpMatcher.h> + class FileSystemTest : public QObject { Q_OBJECT @@ -111,6 +113,40 @@ slots: f(); } + void test_copy_with_blacklist() + { + 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.blacklist(new RegexpMatcher("[.]?mcmeta")); + 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_getDesktop() { QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); |