Skip to content

Commit

Permalink
eclipse-jkube#1929 Formatter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
balbusm committed Jan 24, 2023
1 parent cb42518 commit 7c4f9a6
Showing 1 changed file with 127 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,120 +27,119 @@ class ImageNameFullNameParseTest {

public static Stream<Object[]> validData() {
return Stream.of(
new Object[][] {
{
"Repo and Name", "eclipse/eclipse_jkube",
SimpleImageName.builder()
.fullName("eclipse/eclipse_jkube:latest")
.registry(null)
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("latest")
.digest(null)
.build()
},
{
"Repo, Name and Tag", "eclipse/eclipse_jkube:1.3.3.7",
SimpleImageName.builder()
.fullName("eclipse/eclipse_jkube:1.3.3.7")
.registry(null)
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("1.3.3.7")
.digest(null)
.build()
},
{
"Registry, Repo and Name", "docker.io/eclipse/eclipse_jkube",
SimpleImageName.builder()
.fullName("docker.io/eclipse/eclipse_jkube:latest")
.registry("docker.io")
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("latest")
.digest(null)
.build()
},
{"Registry, Repo and Name with special characters",
"long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube",
SimpleImageName.builder()
.fullName("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:latest")
.registry("long.registry.example.com:8080")
.user("valid.name--with__separators")
.repository("valid.name--with__separators/eclipse_jkube")
.tag("latest")
.digest(null)
.build()
},
{"Registry, Repo, Name and Tag", "docker.io/eclipse/eclipse_jkube:1.33.7",
SimpleImageName.builder()
.fullName("docker.io/eclipse/eclipse_jkube:1.33.7")
.registry("docker.io")
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("1.33.7")
.digest(null)
.build()
},
{
"Registry, Repo, Name and Tag with special characters",
"long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A",
SimpleImageName.builder()
.fullName(
"long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A")
.registry("long.registry.example.com:8080")
.user("valid.name--with__separators")
.repository("valid.name--with__separators/eclipse_jkube")
.tag("very--special__tag.2.A")
.digest(null)
.build()
},
{
"Repo only", "eclipse-temurin:11",
SimpleImageName.builder()
.fullName("eclipse-temurin:11")
.registry(null)
.user(null)
.repository("eclipse-temurin")
.tag("11")
.digest(null)
.build()
},
{
"User and repo", "user/my-repo_z:11",
SimpleImageName.builder()
.fullName("user/my-repo_z:11")
.registry(null)
.user("user")
.repository("user/my-repo_z")
.tag("11")
.digest(null)
.build()
},
{
"Registry and repo", "foo-bar-registry.jfrog.io/java:jre-17",
SimpleImageName.builder()
.fullName("foo-bar-registry.jfrog.io/java:jre-17")
.registry("foo-bar-registry.jfrog.io")
.user(null)
.repository("java")
.tag("jre-17")
.digest(null)
.build()
},
{
"JFrog repo", "user.jfrog.io/my-jkube/openjdk:jre-17",
SimpleImageName.builder()
.fullName("user.jfrog.io/my-jkube/openjdk:jre-17")
.registry("user.jfrog.io")
.user("my-jkube")
.repository("my-jkube/openjdk")
.tag("jre-17")
.digest(null)
.build()
},
}
);
new Object[][] {
{
"Repo and Name", "eclipse/eclipse_jkube",
SimpleImageName.builder()
.fullName("eclipse/eclipse_jkube:latest")
.registry(null)
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("latest")
.digest(null)
.build()
},
{
"Repo, Name and Tag", "eclipse/eclipse_jkube:1.3.3.7",
SimpleImageName.builder()
.fullName("eclipse/eclipse_jkube:1.3.3.7")
.registry(null)
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("1.3.3.7")
.digest(null)
.build()
},
{
"Registry, Repo and Name", "docker.io/eclipse/eclipse_jkube",
SimpleImageName.builder()
.fullName("docker.io/eclipse/eclipse_jkube:latest")
.registry("docker.io")
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("latest")
.digest(null)
.build()
},
{ "Registry, Repo and Name with special characters",
"long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube",
SimpleImageName.builder()
.fullName("long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:latest")
.registry("long.registry.example.com:8080")
.user("valid.name--with__separators")
.repository("valid.name--with__separators/eclipse_jkube")
.tag("latest")
.digest(null)
.build()
},
{ "Registry, Repo, Name and Tag", "docker.io/eclipse/eclipse_jkube:1.33.7",
SimpleImageName.builder()
.fullName("docker.io/eclipse/eclipse_jkube:1.33.7")
.registry("docker.io")
.user("eclipse")
.repository("eclipse/eclipse_jkube")
.tag("1.33.7")
.digest(null)
.build()
},
{
"Registry, Repo, Name and Tag with special characters",
"long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A",
SimpleImageName.builder()
.fullName(
"long.registry.example.com:8080/valid.name--with__separators/eclipse_jkube:very--special__tag.2.A")
.registry("long.registry.example.com:8080")
.user("valid.name--with__separators")
.repository("valid.name--with__separators/eclipse_jkube")
.tag("very--special__tag.2.A")
.digest(null)
.build()
},
{
"Repo only", "eclipse-temurin:11",
SimpleImageName.builder()
.fullName("eclipse-temurin:11")
.registry(null)
.user(null)
.repository("eclipse-temurin")
.tag("11")
.digest(null)
.build()
},
{
"User and repo", "user/my-repo_z:11",
SimpleImageName.builder()
.fullName("user/my-repo_z:11")
.registry(null)
.user("user")
.repository("user/my-repo_z")
.tag("11")
.digest(null)
.build()
},
{
"Registry and repo", "foo-bar-registry.jfrog.io/java:jre-17",
SimpleImageName.builder()
.fullName("foo-bar-registry.jfrog.io/java:jre-17")
.registry("foo-bar-registry.jfrog.io")
.user(null)
.repository("java")
.tag("jre-17")
.digest(null)
.build()
},
{
"JFrog repo", "user.jfrog.io/my-jkube/openjdk:jre-17",
SimpleImageName.builder()
.fullName("user.jfrog.io/my-jkube/openjdk:jre-17")
.registry("user.jfrog.io")
.user("my-jkube")
.repository("my-jkube/openjdk")
.tag("jre-17")
.digest(null)
.build()
},
});
}

@ParameterizedTest(name = "{0}")
Expand All @@ -153,25 +152,23 @@ void shouldParseImageName(String testName, String providedImageName, SimpleImage

public static Stream<Object[]> invalidData() {
return Stream.of(
new Object[][]{
{
"Repo and Name with special characters", "invalid.name-with__separators/eclipse_jkube"
},
{
"Repo, Name and Tag with special characters", "invalid.name-with__separators/eclipse_jkube:valid__tag-4.2"
},
}
);
new Object[][] {
{
"Repo and Name with special characters", "invalid.name-with__separators/eclipse_jkube"
},
{
"Repo, Name and Tag with special characters", "invalid.name-with__separators/eclipse_jkube:valid__tag-4.2"
},
});
}

@ParameterizedTest(name = "{0}")
@MethodSource("invalidData")
void shouldFailedParseImageName(String testName, String providedImageName) {
assertThatCode(() -> new ImageName(providedImageName))
.isInstanceOf(IllegalArgumentException.class);
.isInstanceOf(IllegalArgumentException.class);
}


@Builder
@Value
public static class SimpleImageName {
Expand All @@ -184,12 +181,11 @@ public static class SimpleImageName {

public static SimpleImageName toSimpleImageName(ImageName imageName) {
return new SimpleImageName(imageName.getFullName(),
imageName.getRegistry(),
imageName.getUser(),
imageName.getRepository(),
imageName.getTag(),
imageName.getDigest()
);
imageName.getRegistry(),
imageName.getUser(),
imageName.getRepository(),
imageName.getTag(),
imageName.getDigest());
}

}
Expand Down

0 comments on commit 7c4f9a6

Please sign in to comment.