-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(downloader): correct snyk-to-html url
- Loading branch information
Showing
2 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/io/snyk/jenkins/tools/internal/DownloadServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.snyk.jenkins.tools.internal; | ||
|
||
import org.junit.Test; | ||
|
||
import io.snyk.jenkins.tools.Platform; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.IsEqual.equalTo; | ||
import static org.hamcrest.core.IsNull.notNullValue; | ||
|
||
|
||
public class DownloadServiceTest { | ||
|
||
@Test | ||
public void constructDownloadUrlForSnyk_shouldReturnExpectedUrlForCli() throws IOException { | ||
String urlTemplate = "https://downloads.snyk.io/%s/%s/%s"; | ||
String product = "cli"; | ||
String version = "stable"; | ||
String queryParam = "?utm_source=" + DownloadService.SNYK_INTEGRATION_NAME; | ||
Platform platform = Platform.MAC_OS; | ||
|
||
URL expectedUrl = new URL("https://downloads.snyk.io/" + product + "/" + version + "/" + "snyk-macos" + queryParam); | ||
URL actualUrl = DownloadService.constructDownloadUrlForSnyk(urlTemplate, product, version, platform); | ||
|
||
assertThat(actualUrl, notNullValue()); | ||
assertThat(actualUrl, equalTo(expectedUrl)); | ||
} | ||
|
||
@Test | ||
public void constructDownloadUrlForSnyk_shouldReturnExpectedUrlForSnykToHtml() throws IOException { | ||
String urlTemplate = "https://downloads.snyk.io/%s/%s/%s"; | ||
String product = "snyk-to-html"; | ||
String version = "stable"; | ||
String queryParam = "?utm_source=" + DownloadService.SNYK_INTEGRATION_NAME; | ||
Platform platform = Platform.MAC_OS; | ||
|
||
URL expectedUrl = new URL("https://downloads.snyk.io/" + product + "/" + version + "/" + "snyk-to-html-macos" + queryParam); | ||
URL actualUrl = DownloadService.constructDownloadUrlForSnyk(urlTemplate, product, version, platform); | ||
|
||
assertThat(actualUrl, notNullValue()); | ||
assertThat(actualUrl, equalTo(expectedUrl)); | ||
} | ||
} |