Skip to content

Commit

Permalink
test: Add another missing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelsJP committed Oct 20, 2023
1 parent b02154d commit 60663f5
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.junit.jupiter.params.provider.CsvSource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

class ORSInitContextListenerTest {

Expand All @@ -16,16 +17,24 @@ void setUp(){
}
@ParameterizedTest
@CsvSource(value = {
"https://example.com/foo1/foo2/foo3/test-repo, https://example.com, test-repo",
"https://example.com/test-repo/, https://example.com, test-repo",
"https://example.com/test-repo, https://example.com, test-repo",
"' https://example.com/test-repo ', https://example.com, test-repo",
"https://example.com/test-repos/, https://example.com, test-repos",
"http://example.com/test-repo/, http://example.com, test-repo"
"https://example.com/foo1/foo2/foo3/test-repo, https://example.com, test-repo, true",
"https://example.com/test-repo/, https://example.com, test-repo, true",
"https://example.com/test-repo, https://example.com, test-repo, true",
"' https://example.com/test-repo ', https://example.com, test-repo, true",
"https://example.com/test-repos/, https://example.com, test-repos, true",
"http://example.com/test-repo/, http://example.com, test-repo, true",
"/foo/test-repo/, null, null, false"
})
void extractSourceFileElements_withURL(String url, String expectedBaseUrl, String expectedRepoName){
void extractSourceFileElements_withURL(String url, String expectedBaseUrl, String expectedRepoName, Boolean isUrl){
ORSInitContextListener.SourceFileElements elements = orsInitContextListener.extractSourceFileElements(url);
assertEquals(expectedBaseUrl, elements.repoBaseUrlString());
assertEquals(expectedRepoName, elements.repoName());
if (isUrl) {
assertEquals(expectedBaseUrl, elements.repoBaseUrlString());
assertEquals(expectedRepoName, elements.repoName());
assertEquals("", elements.localOsmFilePath());
} else {
assertEquals(url, elements.localOsmFilePath());
assertNull(elements.repoBaseUrlString());
assertNull(elements.repoName());
}
}
}

0 comments on commit 60663f5

Please sign in to comment.