Skip to content

Commit

Permalink
fixup! Support raw devfile urls without yaml extension
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed May 13, 2024
1 parent 58cc77f commit 974595e
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ public void shouldAcceptRawDevfileUrl(String url) {
assertTrue(result);
}

@Test(dataProvider = "devfileUrlsWithoutExtension")
public void shouldAcceptRawDevfileUrlWithoutExtension(String url) throws Exception {
// given
JsonNode jsonNode = mock(JsonNode.class);
when(urlFetcher.fetch(eq(url))).thenReturn(DEVFILE);
when(devfileParser.parseYamlRaw(eq(DEVFILE))).thenReturn(jsonNode);
when(jsonNode.isEmpty()).thenReturn(false);

// when
boolean result =
rawDevfileUrlFactoryParameterResolver.accept(singletonMap(URL_PARAMETER_NAME, url));

// then
assertTrue(result);
}

@Test
public void shouldAcceptRawDevfileUrlWithYaml() throws Exception {
// given
Expand Down Expand Up @@ -238,12 +254,15 @@ private Object[] devfileUrls() {
"https://host/path/.devfile.yaml",
"https://host/path/any-name.yaml",
"https://host/path/any-name.yml",
"https://host/path/any-name",
"https://host/path/devfile.yaml?token=TOKEN123",
"https://host/path/.devfile.yaml?token=TOKEN123",
"https://host/path/any-name.yaml?token=TOKEN123",
"https://host/path/any-name.yml?token=TOKEN123",
"https://host/path/any-name?token=TOKEN123"
"https://host/path/any-name.yml?token=TOKEN123"
};
}

@DataProvider(name = "devfileUrlsWithoutExtension")
private Object[] devfileUrlsWithoutExtension() {
return new String[] {"https://host/path/any-name", "https://host/path/any-name?token=TOKEN123"};
}
}

0 comments on commit 974595e

Please sign in to comment.