@@ -2,7 +2,6 @@ package e2e
2
2
3
3
import (
4
4
"bufio"
5
- "fmt"
6
5
"path/filepath"
7
6
"regexp"
8
7
"strings"
@@ -25,10 +24,8 @@ func insertBundles(t *testing.T, cmd icmd.Cmd) {
25
24
func assertImageListOutput (t * testing.T , cmd icmd.Cmd , expected string ) {
26
25
result := icmd .RunCmd (cmd ).Assert (t , icmd .Success )
27
26
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 )
32
29
assert .Assert (t , match )
33
30
}
34
31
@@ -42,22 +39,18 @@ func expectImageListDigestsOutput(t *testing.T, cmd icmd.Cmd, output string) {
42
39
assertImageListOutput (t , cmd , output )
43
40
}
44
41
45
- func verifyImageIDListOutput (t * testing.T , cmd icmd.Cmd , count int , distinct int ) {
42
+ func verifyImageIDListOutput (t * testing.T , cmd icmd.Cmd , expectedCount int ) {
46
43
cmd .Command = dockerCli .Command ("app" , "image" , "ls" , "-q" )
47
44
result := icmd .RunCmd (cmd ).Assert (t , icmd .Success )
48
45
scanner := bufio .NewScanner (strings .NewReader (result .Stdout ()))
49
- lines := []string {}
50
- counter := make (map [string ]int )
46
+ count := 0
51
47
for scanner .Scan () {
52
- lines = append (lines , scanner .Text ())
53
- counter [scanner .Text ()]++
54
- fmt .Println (scanner .Text ())
48
+ count ++
55
49
}
56
50
if err := scanner .Err (); err != nil {
57
51
assert .Error (t , err , "Verification failed" )
58
52
}
59
- assert .Equal (t , len (lines ), count )
60
- assert .Equal (t , len (counter ), distinct )
53
+ assert .Equal (t , expectedCount , count )
61
54
}
62
55
63
56
func TestImageList (t * testing.T ) {
@@ -79,7 +72,7 @@ func TestImageListQuiet(t *testing.T) {
79
72
runWithDindSwarmAndRegistry (t , func (info dindSwarmAndRegistryInfo ) {
80
73
cmd := info .configuredCmd
81
74
insertBundles (t , cmd )
82
- verifyImageIDListOutput (t , cmd , 3 , 3 )
75
+ verifyImageIDListOutput (t , cmd , 3 )
83
76
})
84
77
}
85
78
0 commit comments