-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default labels to images created with
ImageFromDockerfile
(#2809)
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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
27 changes: 27 additions & 0 deletions
27
core/src/test/java/org/testcontainers/images/builder/ImageFromDockerfileTest.java
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,27 @@ | ||
package org.testcontainers.images.builder; | ||
|
||
import com.github.dockerjava.api.DockerClient; | ||
import com.github.dockerjava.api.command.InspectImageResponse; | ||
import org.junit.Test; | ||
import org.testcontainers.DockerClientFactory; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ImageFromDockerfileTest { | ||
|
||
@Test | ||
public void shouldAddDefaultLabels() { | ||
ImageFromDockerfile image = new ImageFromDockerfile() | ||
.withDockerfileFromBuilder(it -> it.from("scratch")); | ||
|
||
String imageId = image.resolve(); | ||
|
||
DockerClient dockerClient = DockerClientFactory.instance().client(); | ||
|
||
InspectImageResponse inspectImageResponse = dockerClient.inspectImageCmd(imageId).exec(); | ||
|
||
assertThat(inspectImageResponse.getConfig().getLabels()) | ||
.containsAllEntriesOf(DockerClientFactory.DEFAULT_LABELS); | ||
} | ||
|
||
} |