From 2681ae411908eb9b8858d3e5b608598c647fe508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 14 Jun 2024 20:14:13 +0200 Subject: [PATCH] feat: add testcontainers labels to the built images (#2579) * chore: add testcontainers labels to the built images * fix: update test --- container.go | 4 ++++ docker_test.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/container.go b/container.go index 108f5df3f1..c08d45624d 100644 --- a/container.go +++ b/container.go @@ -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 } diff --git a/docker_test.go b/docker_test.go index 9d3593d040..5e249d60fa 100644 --- a/docker_test.go +++ b/docker_test.go @@ -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]) } }