Skip to content

Commit

Permalink
fix(test): iterateanddownload test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Aug 2, 2024
1 parent e40c981 commit a9de926
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Install Maven for Acceptance Tests
run: |
mvn -N "wrapper:wrapper" "-Dmaven=${{matrix.maven_version}}"
mvn -N "io.takari:maven:0.7.7:wrapper" "-Dmaven=${{matrix.maven_version}}"
./mvnw --version
- name: Install Plugin to .m2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public static File ensure(URL cliDownloadURL, File cliFile, String updatePolicy,
if (cliFile.exists() && checksumFile.exists()) {
if (verifyChecksum(cliFile, checksumFile)) {
if (!shouldUpdate(
updatePolicy,
cliFile.lastModified(),
System.currentTimeMillis()
updatePolicy,
cliFile.lastModified(),
System.currentTimeMillis()
)) {
return cliFile;
}
Expand All @@ -54,6 +54,7 @@ public static File ensure(URL cliDownloadURL, File cliFile, String updatePolicy,

cliFile.delete();
checksumFile.delete();
cliFile.getParentFile().mkdirs();

downloader.download(cliDownloadURL, cliFile);

Expand Down Expand Up @@ -92,7 +93,7 @@ public static File iterateAndEnsure(List<URL> cliDownloadURLs, File cliFile, Str
return downloadedFile;
}
} catch (RuntimeException e) {
System.err.println("Failed to download from '" + cliDownloadURL + "': " + e.getMessage());
System.err.println("Failed to download from '" + cliDownloadURL + "': " + e);
}
}
throw new RuntimeException("Failed to download from URLs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public void throwsWhenShaDoesntMatch() throws Exception {
@Test
public void iteratesToNextURLOnDownloadFailure() throws Exception {
// Mock objects
File cliFile = new File("snyk-macos");
Path tempDirectory = Files.createTempDirectory(getClass().getSimpleName());
Path cliPath = tempDirectory.resolve("snyk-macos");
File cliFile = new File(cliPath.toString());

FileDownloader mockDownloader = (URL url, File target) -> {
if (url.toString().contains("https://fail.download/")) {
throw new IOException("mock download failure");
Expand Down

0 comments on commit a9de926

Please sign in to comment.