Skip to content

Commit

Permalink
Refactor to support separate cloud rename page
Browse files Browse the repository at this point in the history
  • Loading branch information
car-roll committed Sep 13, 2023
1 parent 9fb646e commit e88d5df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<properties>
<revision>1.6</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.387.3</jenkins.version>
<jenkins.version>2.423-rc34199.8c3d6c65b_758</jenkins.version>
<!-- TODO: https://github.com/jenkinsci/jenkins/pull/8310 -->
<gitHubRepo>jenkinsci/docker-plugin</gitHubRepo>
<!-- Our unit-tests that talk to a real docker deamon aren't very stable -->
<surefire.rerunFailingTestsCount>3</surefire.rerunFailingTestsCount>
Expand All @@ -76,7 +77,7 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.387.x</artifactId>
<artifactId>bom-2.414.x</artifactId>
<version>2401.v7a_d68f8d0b_09</version>
<type>pom</type>
<scope>import</scope>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:c="/lib/credentials" >

<f:entry title="${%Name}" field="name">
<f:textbox default="docker"/>
</f:entry>

<f:advanced title="${%Docker Cloud details}" align="left">

<f:property field="dockerApi"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,14 @@ public void testConstructor_0_10_2() {

private static final String LOG_MESSAGE = "Docker cloud requires a non-blank name after Jenkins 2.402";

@Issue("JENKINS-70729") // Warn if cloud name is empty
@Test
public void testConstructorWithEmptyName() {
lr.record(DockerCloud.class.getName(), Level.ALL).capture(16);
DockerCloud cloud =
new DockerCloud("", new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of());
Assert.assertEquals(cloud.getDisplayName(), "");
MatcherAssert.assertThat(lr.getMessages(), IsIterableContaining.hasItem(LOG_MESSAGE));
}

@Issue("JENKINS-70729") // Warn if cloud name is null
@Test
public void testConstructorWithNullName() {
lr.record(DockerCloud.class.getName(), Level.ALL).capture(16);
DockerCloud cloud =
new DockerCloud(null, new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of());
Assert.assertEquals(cloud.getDisplayName(), null);
MatcherAssert.assertThat(lr.getMessages(), IsIterableContaining.hasItem(LOG_MESSAGE));
}

@Issue("JENKINS-70729") // Handle null or empty cloud name
@Test
public void testCopyConstructor() {
lr.record(DockerCloud.class.getName(), Level.ALL).capture(16);
DockerCloud cloud =
new DockerCloud(null, new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of());
new DockerCloud("tmp", new DockerAPI(new DockerServerEndpoint("uri", "credentialsId")), List.of());
cloud.name = null;
Assert.assertEquals(cloud.getDisplayName(), null);
MatcherAssert.assertThat(lr.getMessages(), IsIterableContaining.hasItem(LOG_MESSAGE));
String newName = "docker-cloud-" + Integer.toHexString(cloud.hashCode());
DockerCloud copy = new DockerCloud(newName, cloud);
Assert.assertEquals(cloud.getDockerApi(), copy.getDockerApi());
Expand Down

0 comments on commit e88d5df

Please sign in to comment.