-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing test and docs for docker registry credentials feature from …
- Loading branch information
1 parent
2530878
commit 256bc2b
Showing
3 changed files
with
74 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/com/cloudogu/gitopsbuildlib/docker/DockerWrapperTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.cloudogu.gitopsbuildlib.docker | ||
|
||
import com.cloudogu.gitopsbuildlib.ScriptMock | ||
import org.junit.jupiter.api.Test | ||
|
||
import static org.assertj.core.api.Assertions.assertThat | ||
|
||
class DockerWrapperTest { | ||
|
||
public static final String EXPECTED_IMAGE = 'ghcr.io/cloudogu/helm:3.11.1-2' | ||
|
||
def scriptMock = new ScriptMock() | ||
|
||
def dockerWrapper = new DockerWrapper(scriptMock.mock) | ||
|
||
def imageConfigMap = [ | ||
image: EXPECTED_IMAGE, | ||
] | ||
def imageConfigMapWithCredentials = [ | ||
image: EXPECTED_IMAGE, | ||
credentialsId: 'myCredentials' | ||
] | ||
def imageConfigString = EXPECTED_IMAGE | ||
|
||
@Test | ||
void 'works with imageConfig string'() { | ||
|
||
dockerWrapper.withDockerImage(imageConfigString) { | ||
} | ||
assertThat(scriptMock.dockerMock.actualImages[0]).isEqualTo(EXPECTED_IMAGE) | ||
} | ||
|
||
@Test | ||
void 'works with imageConfig Map'() { | ||
dockerWrapper.withDockerImage(imageConfigMap) { | ||
} | ||
assertThat(scriptMock.dockerMock.actualImages[0]).isEqualTo(EXPECTED_IMAGE) | ||
} | ||
|
||
@Test | ||
void 'works with imageConfig Map with Credentials'() { | ||
dockerWrapper.withDockerImage(imageConfigMapWithCredentials) { | ||
} | ||
assertThat(scriptMock.dockerMock.actualImages[0]).isEqualTo(EXPECTED_IMAGE) | ||
assertThat(scriptMock.dockerMock.actualRegistryArgs[0]).isEqualTo('https://ghcr.io/cloudogu') | ||
assertThat(scriptMock.dockerMock.actualRegistryArgs[1]).isEqualTo('myCredentials') | ||
} | ||
} |