|
1 | 1 | package fr.formiko.utils;
|
2 | 2 |
|
3 |
| -import fr.formiko.utils.progressions.FLUProgressionCLI; |
4 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
5 | 4 | import static org.junit.jupiter.api.Assertions.assertNull;
|
6 | 5 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
@@ -333,8 +332,43 @@ private static Stream<Arguments> testDownloadSource() {
|
333 | 332 | Arguments.of("https://unexisting.url", false, TEST_PATH_TEMPORARY + "unexisting.url", null));
|
334 | 333 | }
|
335 | 334 |
|
| 335 | + @ParameterizedTest |
| 336 | + @MethodSource("testDownloadAndUnzipSource") |
| 337 | + void testDownloadAndUnzip(String url, boolean shouldWork, String destination, String fileToCheck, String directoryInsideZipToGet) { |
| 338 | + assertEquals(shouldWork, FLUFiles.downloadAndUnzip(url, destination, directoryInsideZipToGet)); |
| 339 | + if (shouldWork) { |
| 340 | + assertTrue(new File(fileToCheck).exists()); |
| 341 | + assertEquals(true, FLUFiles.delete(destination)); |
| 342 | + } |
| 343 | + } |
| 344 | + |
| 345 | + private static Stream<Arguments> testDownloadAndUnzipSource() { |
| 346 | + return Stream.of( |
| 347 | + Arguments.of("https://github.com/HydrolienF/Kokcinelo/releases/download/3.0.20/KokcineloLauncher.zip", true, |
| 348 | + TEST_PATH_TEMPORARY + "kl1/", TEST_PATH_TEMPORARY + "kl1/" + "Kokcinelo3.0.20/", "Kokcinelo3.0.20/"), |
| 349 | + Arguments.of("https://github.com/HydrolienF/Kokcinelo/releases/download/3.0.20/KokcineloLauncher.zip", true, |
| 350 | + TEST_PATH_TEMPORARY + "kl2/", TEST_PATH_TEMPORARY + "kl2/" + "", "Kokcinelo3.0.20/"), |
| 351 | + Arguments.of("https://github.com/HydrolienF/Kokcinelo/releases/download/3.0.20/KokcineloLauncher.zip", true, |
| 352 | + TEST_PATH_TEMPORARY + "kl3/", TEST_PATH_TEMPORARY + "kl3/" + "Kokcinelo3.0.20", "Kokcinelo3.0.20/"), |
| 353 | + Arguments.of("https://github.com/HydrolienF/Kokcinelo/releases/download/3.0.20/KokcineloLauncher.zip", true, |
| 354 | + TEST_PATH_TEMPORARY + "kl4/", TEST_PATH_TEMPORARY + "kl4/" + "icon.png", "Kokcinelo3.0.20/icon.png"), |
| 355 | + Arguments.of("https://github.com/HydrolienF/Kokcinelo/releases/download/3.0.20/KokcineloLauncher.zip", true, |
| 356 | + TEST_PATH_TEMPORARY + "kl5/", TEST_PATH_TEMPORARY + "kl5/" + "icon.ico", "Kokcinelo3.0.20/icon.ico"), |
| 357 | + Arguments.of("https://github.com/HydrolienF/Formiko/releases/download/2.29.23/Formiko2.29.23Linux.zip", true, |
| 358 | + TEST_PATH_TEMPORARY + "kl6/", TEST_PATH_TEMPORARY + "kl6/" + "java/", "Formiko2.29.23Linux/java/"), |
| 359 | + Arguments.of("https://github.com/HydrolienF/Formiko/releases/download/2.29.23/Formiko2.29.23Linux.zip", true, |
| 360 | + TEST_PATH_TEMPORARY + "kl6/", TEST_PATH_TEMPORARY + "kl6/" + "java", "Formiko2.29.23Linux/java"), |
| 361 | + Arguments.of("https://unexisting.url", false, TEST_PATH_TEMPORARY + "unexisting.url", null, "")); |
| 362 | + } |
| 363 | + |
336 | 364 | public static void main(String[] args) {
|
337 |
| - FLUFiles.setProgression(new FLUProgressionCLI()); |
338 |
| - FLUFiles.createFile(TEST_PATH_TEMPORARY + "/testCreateFiles1.txt"); |
| 365 | + // FLUFiles.setProgression(new FLUProgressionCLI()); |
| 366 | + // FLUFiles.createFile(TEST_PATH_TEMPORARY + "/testCreateFiles1.txt"); |
| 367 | + // Arguments.of("https://github.com/HydrolienF/Kokcinelo/releases/download/3.0.20/KokcineloLauncher.zip", true, |
| 368 | + // TEST_PATH_TEMPORARY + "kl1/", TEST_PATH_TEMPORARY + "kl1/" + "KokcineloLauncher/", "") |
| 369 | + clean(); |
| 370 | + System.out |
| 371 | + .println(FLUFiles.downloadAndUnzip("https://github.com/HydrolienF/Kokcinelo/releases/download/3.0.20/KokcineloLauncher.zip", |
| 372 | + TEST_PATH_TEMPORARY, "Kokcinelo3.0.20/icon.png")); |
339 | 373 | }
|
340 | 374 | }
|
0 commit comments