Skip to content

Commit

Permalink
Update ImageNameTest.java
Browse files Browse the repository at this point in the history
added test case
  • Loading branch information
Devashishbasu committed Jan 19, 2024
1 parent 7249365 commit d07beb7
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ private void verifyData(Object[] data) {
@Test
void testIllegalFormat() {
assertThrows(IllegalArgumentException.class, () -> new ImageName(""));

// New test for too long repository name
String tooLongName = generateTooLongImageName();
assertThatIllegalArgumentException()
.as("Too long image name should fail")
.isThrownBy(() -> new ImageName(tooLongName))
.withMessageContaining("Repository name must not be more than 255 characters");
}

private String generateTooLongImageName() {
StringBuilder tooLongName = new StringBuilder();
int maxLength = 255 + 1; // exceeding the maximum length
for (int i = 0; i < maxLength; i++) {
tooLongName.append("a");
}
return tooLongName.toString();
}

@Test
Expand Down

0 comments on commit d07beb7

Please sign in to comment.