Skip to content

Commit

Permalink
test: fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Aug 2, 2024
1 parent cf64df3 commit ecba03a
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,19 @@ public void iteratesToNextURLOnDownloadFailure() throws Exception {
File cliFile = new File(cliPath.toString());

FileDownloader mockDownloader = (URL url, File target) -> {
if (url.toString().contains("https://fail.download/")) {
if (url.toString().contains("https://downloads.snyk.io/cli/")) {
throw new IOException("mock download failure");
}
if (url.toString().equals("https://static.snyk.io/cli/stable/snyk-macos.sha256")) {
if (url.toString().equals("https://static.snyk.io/cli/1.1292.0/snyk-macos.sha256?utm_source=MAVEN_PLUGIN")) {
Files.write(target.toPath(), helloWorldShasum);
}
if (url.toString().equals("https://static.snyk.io/cli/stable/snyk-macos")) {
if (url.toString().equals("https://static.snyk.io/cli/1.1292.0/snyk-macos?utm_source=MAVEN_PLUGIN")) {
Files.write(target.toPath(), helloWorldBytes);
}
};

// Prepare test data
URL url1 = new URL("https://fail.download/cli/stable/snyk-macos");
URL url2 = new URL("https://static.snyk.io/cli/stable/snyk-macos");

List<URL> urls = Arrays.asList(url1, url2);
List<URL> urls = ExecutableDownloader.getDownloadUrls(Platform.MAC_OS, "1.1292.0");

// Call the method
File result = ExecutableDownloader.iterateAndEnsure(urls, cliFile, "never", mockDownloader);
Expand Down

0 comments on commit ecba03a

Please sign in to comment.