Skip to content

Commit ef75db4

Browse files
committed
PathProviderTest.getImageUrl covered with tests
1 parent 888ee39 commit ef75db4

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/main/java/io/visual_regression_tracker/sdk_java/PathProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public String getTestRunPath() {
2323
}
2424

2525
public String getImageUrl(String name) {
26-
if(name.isEmpty()){
26+
if(name == null || name.isEmpty()){
2727
return null;
2828
}
2929
return baseApiUrl.concat("/").concat(name);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.visual_regression_tracker.sdk_java;
2+
3+
import org.testng.annotations.BeforeMethod;
4+
import org.testng.annotations.DataProvider;
5+
import org.testng.annotations.Test;
6+
7+
import static org.hamcrest.CoreMatchers.is;
8+
import static org.hamcrest.MatcherAssert.assertThat;
9+
10+
public class PathProviderTest {
11+
12+
String apiUrl = "http://localhost:4200";
13+
PathProvider pathProvider;
14+
15+
@BeforeMethod()
16+
public void setUp() {
17+
pathProvider = new PathProvider(apiUrl);
18+
}
19+
20+
@DataProvider(name = "shouldGetImageUrlCases")
21+
public Object[][] shouldGetImageUrlCases() {
22+
return new Object[][] {
23+
{null, null}, {"", null}, {"some", apiUrl.concat("/some")},
24+
};
25+
}
26+
27+
@Test(dataProvider = "shouldGetImageUrlCases")
28+
public void shouldGetImageUrl(String imageName, String expectedResult) {
29+
String result = pathProvider.getImageUrl(imageName);
30+
31+
assertThat(result, is(expectedResult));
32+
}
33+
}

0 commit comments

Comments
 (0)