1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

test: docker: improve image label checks

This commit is contained in:
Carlos Alexandro Becker 2019-01-19 16:50:12 -02:00 committed by Carlos Alexandro Becker
parent 98f22d7882
commit a43c653254

View File

@ -7,7 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"syscall"
"testing"
@ -75,12 +75,13 @@ func TestRunPipe(t *testing.T) {
var shouldFindImagesWithLabels = func(image string, filters ...string) func(*testing.T, int) {
return func(t *testing.T, count int) {
for _, filter := range filters {
output, err := exec.Command("docker", "images", "--filter", filter).CombinedOutput()
output, err := exec.Command(
"docker", "images", "-q", "*/"+image,
"--filter", filter,
).CombinedOutput()
require.NoError(t, err)
matcher := regexp.MustCompile(image)
matches := matcher.FindAllStringIndex(string(output), -1)
require.Equal(t, count, len(matches))
lines := strings.Split(strings.TrimSpace(string(output)), "\n")
require.Equal(t, count, len(lines))
}
}
@ -148,7 +149,8 @@ func TestRunPipe(t *testing.T) {
"label=org.label-schema.schema-version=1.0",
"label=org.label-schema.version=1.0.0",
"label=org.label-schema.vcs-ref=a1b2c3d4",
"label=org.label-schema.name=mybin"),
"label=org.label-schema.name=mybin",
),
assertError: shouldNotErr,
pubAssertError: shouldNotErr,
},