| 7 | #include "minecraft/mod/ModFolderModel.h" |
| 8 | |
| 9 | class ModFolderModelTest : public QObject |
| 10 | { |
| 11 | Q_OBJECT |
| 12 | |
| 13 | private |
| 14 | slots: |
| 15 | // test for GH-1178 - install a folder with files to a mod list |
| 16 | void test_1178() |
| 17 | { |
| 18 | // source |
| 19 | QString source = QFINDTESTDATA("data/test_folder"); |
| 20 | |
| 21 | // sanity check |
| 22 | QVERIFY(!source.endsWith('/')); |
| 23 | |
| 24 | auto verify = [](QString path) |
| 25 | { |
| 26 | QDir target_dir(FS::PathCombine(path, "test_folder")); |
| 27 | QVERIFY(target_dir.entryList().contains("pack.mcmeta")); |
| 28 | QVERIFY(target_dir.entryList().contains("assets")); |
| 29 | }; |
| 30 | |
| 31 | // 1. test with no trailing / |
| 32 | { |
| 33 | QString folder = source; |
| 34 | QTemporaryDir tempDir; |
| 35 | ModFolderModel m(tempDir.path()); |
| 36 | m.installMod(folder); |
| 37 | verify(tempDir.path()); |
| 38 | } |
| 39 | |
| 40 | // 2. test with trailing / |
| 41 | { |
| 42 | QString folder = source + '/'; |
| 43 | QTemporaryDir tempDir; |
| 44 | ModFolderModel m(tempDir.path()); |
| 45 | m.installMod(folder); |
| 46 | verify(tempDir.path()); |
| 47 | } |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | QTEST_GUILESS_MAIN(ModFolderModelTest) |
| 52 |
nothing calls this directly
no test coverage detected