MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / test_link

Method test_link

tests/FileSystem_test.cpp:309–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307 void test_getDesktop() { QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); }
308
309 void test_link()
310 {
311 QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder");
312 auto f = [&folder]() {
313 QTemporaryDir tempDir;
314 tempDir.setAutoRemove(true);
315 qDebug() << "From:" << folder << "To:" << tempDir.path();
316
317 QDir target_dir(FS::PathCombine(tempDir.path(), "test_folder"));
318 qDebug() << tempDir.path();
319 qDebug() << target_dir.path();
320
321 LinkTask lnk_tsk(folder, target_dir.path());
322 lnk_tsk.linkRecursively(false);
323 connect(&lnk_tsk, &Task::finished,
324 [&lnk_tsk] { QVERIFY2(lnk_tsk.wasSuccessful(), "Task finished but was not successful when it should have been."); });
325 lnk_tsk.start();
326
327 QVERIFY2(QTest::qWaitFor([&lnk_tsk]() { return lnk_tsk.isFinished(); }, 100000), "Task didn't finish as it should.");
328
329 for (auto entry : target_dir.entryList()) {
330 qDebug() << entry;
331 QFileInfo entry_lnk_info(target_dir.filePath(entry));
332 if (!entry_lnk_info.isDir())
333 QVERIFY(!entry_lnk_info.isSymLink());
334 }
335
336 QFileInfo lnk_info(target_dir.path());
337 QVERIFY(lnk_info.exists());
338 QVERIFY(lnk_info.isSymLink());
339
340 QVERIFY(target_dir.entryList().contains("pack.mcmeta"));
341 QVERIFY(target_dir.entryList().contains("assets"));
342 };
343
344 // first try variant without trailing /
345 QVERIFY(!folder.endsWith('/'));
346 f();
347
348 // then variant with trailing /
349 folder.append('/');
350 QVERIFY(folder.endsWith('/'));
351 f();
352 }
353
354 void test_hard_link()
355 {

Callers

nothing calls this directly

Calls 11

PathCombineFunction · 0.85
linkRecursivelyMethod · 0.80
wasSuccessfulMethod · 0.80
isFinishedMethod · 0.80
filePathMethod · 0.80
appendMethod · 0.80
pathMethod · 0.45
startMethod · 0.45
isSymLinkMethod · 0.45
existsMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected