Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 349c8a3

Browse files
committed
Cleanup app image ls tests
Cleaned up app image ls tests to remove: - Debug messages - No longer necessary distinct vs total count test for `image ls --quiet`. Addition of the creation date to the bundle ensures that the image ID will always be unique. Signed-off-by: Nick Adcock <[email protected]>
1 parent 9fb9b2d commit 349c8a3

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

e2e/images_test.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package e2e
22

33
import (
44
"bufio"
5-
"fmt"
65
"path/filepath"
76
"regexp"
87
"strings"
@@ -25,10 +24,8 @@ func insertBundles(t *testing.T, cmd icmd.Cmd) {
2524
func assertImageListOutput(t *testing.T, cmd icmd.Cmd, expected string) {
2625
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
2726
stdout := result.Stdout()
28-
match, _ := regexp.MatchString(expected, stdout)
29-
if !match {
30-
fmt.Println(stdout)
31-
}
27+
match, err := regexp.MatchString(expected, stdout)
28+
assert.NilError(t, err)
3229
assert.Assert(t, match)
3330
}
3431

@@ -42,22 +39,18 @@ func expectImageListDigestsOutput(t *testing.T, cmd icmd.Cmd, output string) {
4239
assertImageListOutput(t, cmd, output)
4340
}
4441

45-
func verifyImageIDListOutput(t *testing.T, cmd icmd.Cmd, count int, distinct int) {
42+
func verifyImageIDListOutput(t *testing.T, cmd icmd.Cmd, expectedCount int) {
4643
cmd.Command = dockerCli.Command("app", "image", "ls", "-q")
4744
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
4845
scanner := bufio.NewScanner(strings.NewReader(result.Stdout()))
49-
lines := []string{}
50-
counter := make(map[string]int)
46+
count := 0
5147
for scanner.Scan() {
52-
lines = append(lines, scanner.Text())
53-
counter[scanner.Text()]++
54-
fmt.Println(scanner.Text())
48+
count++
5549
}
5650
if err := scanner.Err(); err != nil {
5751
assert.Error(t, err, "Verification failed")
5852
}
59-
assert.Equal(t, len(lines), count)
60-
assert.Equal(t, len(counter), distinct)
53+
assert.Equal(t, expectedCount, count)
6154
}
6255

6356
func TestImageList(t *testing.T) {
@@ -79,7 +72,7 @@ func TestImageListQuiet(t *testing.T) {
7972
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
8073
cmd := info.configuredCmd
8174
insertBundles(t, cmd)
82-
verifyImageIDListOutput(t, cmd, 3, 3)
75+
verifyImageIDListOutput(t, cmd, 3)
8376
})
8477
}
8578

0 commit comments

Comments
 (0)