Skip to content

Commit

Permalink
Add unit test for remove trailing slash func
Browse files Browse the repository at this point in the history
  • Loading branch information
dionisislolas committed Jul 10, 2024
1 parent 6793ab6 commit 92b5626
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void sendChunk(byte[] chunk, int chunkNumber, int totalChunks, String fi
}
}

private String removeTrailingSlash(String url){
protected String removeTrailingSlash(String url){
if (url.endsWith("/")) {
return url.substring(0, url.length() - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down Expand Up @@ -90,4 +91,14 @@ void handingIncorrectTokenProvidedResumableFile() {

assertNotNull(e.getCause());
}

@Test
void testRemoveTrailingSlash() {
String url = "http://www.ons.gov.uk//";
String expected = "http://www.ons.gov.uk/";
APIClient client = new APIClient("http://localhost:123456789", TOKEN);
String result = client.removeTrailingSlash(url);
assertNotNull(result);
assertEquals(expected, result);
}
}

0 comments on commit 92b5626

Please sign in to comment.