Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #739 from zappy-shu/add-creation-to-bundles
Browse files Browse the repository at this point in the history
PR followup for add creation to bundles
  • Loading branch information
silvin-lubecki authored Nov 14, 2019
2 parents aaa673f + d324765 commit b0bb564
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
21 changes: 7 additions & 14 deletions e2e/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package e2e

import (
"bufio"
"fmt"
"path/filepath"
"regexp"
"strings"
Expand All @@ -25,10 +24,8 @@ func insertBundles(t *testing.T, cmd icmd.Cmd) {
func assertImageListOutput(t *testing.T, cmd icmd.Cmd, expected string) {
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
stdout := result.Stdout()
match, _ := regexp.MatchString(expected, stdout)
if !match {
fmt.Println(stdout)
}
match, err := regexp.MatchString(expected, stdout)
assert.NilError(t, err)
assert.Assert(t, match)
}

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

func verifyImageIDListOutput(t *testing.T, cmd icmd.Cmd, count int, distinct int) {
func verifyImageIDListOutput(t *testing.T, cmd icmd.Cmd, expectedCount int) {
cmd.Command = dockerCli.Command("app", "image", "ls", "-q")
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
scanner := bufio.NewScanner(strings.NewReader(result.Stdout()))
lines := []string{}
counter := make(map[string]int)
count := 0
for scanner.Scan() {
lines = append(lines, scanner.Text())
counter[scanner.Text()]++
fmt.Println(scanner.Text())
count++
}
if err := scanner.Err(); err != nil {
assert.Error(t, err, "Verification failed")
}
assert.Equal(t, len(lines), count)
assert.Equal(t, len(counter), distinct)
assert.Equal(t, expectedCount, count)
}

func TestImageList(t *testing.T) {
Expand All @@ -79,7 +72,7 @@ func TestImageListQuiet(t *testing.T) {
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
cmd := info.configuredCmd
insertBundles(t, cmd)
verifyImageIDListOutput(t, cmd, 3, 3)
verifyImageIDListOutput(t, cmd, 3)
})
}

Expand Down
2 changes: 1 addition & 1 deletion internal/packager/cnab.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func ToCNAB(app *types.App, invocationImageName string) (*bundle.Bundle, error)
SchemaVersion: CNABVersion1_0_0,
Custom: map[string]interface{}{
internal.CustomDockerAppName: DockerAppCustom{
Version: DockerAppCustomVersion1_0_0,
Version: DockerAppCustomVersionCurrent,
Payload: payload,
},
},
Expand Down

0 comments on commit b0bb564

Please sign in to comment.