chore(tests): add test for copy operation with blacklist

I almost 💀 because no tests used this x.x

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-09-12 13:12:55 -03:00
parent ee0fb2d0e0
commit 931d6c280a
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469

View File

@ -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));