Skip to content

Commit

Permalink
feat: add testcontainers labels to the built images (#2579)
Browse files Browse the repository at this point in the history
* chore: add testcontainers labels to the built images

* fix: update test
  • Loading branch information
mdelapenya committed Jun 14, 2024
1 parent 5d68a52 commit 2681ae4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ func (c *ContainerRequest) BuildOptions() (types.ImageBuildOptions, error) {
buildOptions.Tags = []string{tag}
}

if !c.ShouldKeepBuiltImage() {
buildOptions.Labels = core.DefaultLabels(core.SessionID())
}

return buildOptions, nil
}

Expand Down
4 changes: 2 additions & 2 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ func Test_BuildContainerFromDockerfileWithBuildLog(t *testing.T) {
os.Stdout = rescueStdout
temp := strings.Split(string(out), "\n")

if !regexp.MustCompile(`(?i)^Step\s*1/1\s*:\s*FROM docker.io/alpine$`).MatchString(temp[0]) {
t.Errorf("Expected stdout firstline to be %s. Got '%s'.", "Step 1/1 : FROM docker.io/alpine", temp[0])
if !regexp.MustCompile(`^Step\s*1/\d+\s*:\s*FROM docker.io/alpine$`).MatchString(temp[0]) {
t.Errorf("Expected stdout firstline to be %s. Got '%s'.", "Step 1/* : FROM docker.io/alpine", temp[0])
}
}

Expand Down

0 comments on commit 2681ae4

Please sign in to comment.