@@ -2,7 +2,6 @@ package e2e
22
33import (
44 "bufio"
5- "fmt"
65 "path/filepath"
76 "regexp"
87 "strings"
@@ -25,10 +24,8 @@ func insertBundles(t *testing.T, cmd icmd.Cmd) {
2524func 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
6356func 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