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:
parent
ee0fb2d0e0
commit
931d6c280a
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
|
|
||||||
|
#include <pathmatcher/RegexpMatcher.h>
|
||||||
|
|
||||||
class FileSystemTest : public QObject
|
class FileSystemTest : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -111,6 +113,40 @@ slots:
|
|||||||
f();
|
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()
|
void test_getDesktop()
|
||||||
{
|
{
|
||||||
QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
||||||
|
Loading…
Reference in New Issue
Block a user