@@ -20,31 +20,58 @@ b-simple-app latest simple
2020`
2121)
2222
23+ func insertBundles (t * testing.T , cmd icmd.Cmd , dir * fs.Dir , info dindSwarmAndRegistryInfo ) string {
24+ // Push an application so that we can later pull it by digest
25+ cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , info .registryAddress + "/c-myapp" , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
26+ r := icmd .RunCmd (cmd ).Assert (t , icmd .Success )
27+
28+ // Get the digest from the output of the pull command
29+ out := r .Stdout ()
30+ matches := reg .FindAllStringSubmatch (out , 1 )
31+ digest := matches [0 ][1 ]
32+
33+ // Pull the app by digest
34+ cmd .Command = dockerCli .Command ("app" , "pull" , info .registryAddress + "/c-myapp@" + digest )
35+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
36+
37+ cmd .Command = dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "b-simple-app" , "--output" , dir .Join ("simple-bundle.json" ))
38+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
39+ cmd .Command = dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "a-simple-app" , "--output" , dir .Join ("simple-bundle.json" ))
40+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
41+
42+ return digest
43+ }
44+
2345func TestImageList (t * testing.T ) {
2446 runWithDindSwarmAndRegistry (t , func (info dindSwarmAndRegistryInfo ) {
2547 cmd := info .configuredCmd
2648 dir := fs .NewDir (t , "" )
2749 defer dir .Remove ()
2850
29- // Push an application so that we can later pull it by digest
30- cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , info .registryAddress + "/c-myapp" , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
31- r := icmd .RunCmd (cmd ).Assert (t , icmd .Success )
51+ insertBundles (t , cmd , dir , info )
52+
53+ expectedOutput := fmt .Sprintf (expected , info .registryAddress + "/c-myapp" )
54+ cmd .Command = dockerCli .Command ("app" , "image" , "ls" )
55+ result := icmd .RunCmd (cmd ).Assert (t , icmd .Success )
56+ assert .Equal (t , result .Stdout (), expectedOutput )
57+ })
58+ }
59+
60+ func TestImageRm (t * testing.T ) {
61+ runWithDindSwarmAndRegistry (t , func (info dindSwarmAndRegistryInfo ) {
62+ cmd := info .configuredCmd
63+ dir := fs .NewDir (t , "" )
64+ defer dir .Remove ()
3265
33- // Get the digest from the output of the pull command
34- out := r .Stdout ()
35- matches := reg .FindAllStringSubmatch (out , 1 )
36- digest := matches [0 ][1 ]
66+ digest := insertBundles (t , cmd , dir , info )
3767
38- // Pull the app by digest
39- cmd .Command = dockerCli .Command ("app" , "pull" , info .registryAddress + "/c-myapp@" + digest )
68+ cmd .Command = dockerCli .Command ("app" , "image" , "rm" , info .registryAddress + "/c-myapp@" + digest )
4069 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
4170
42- cmd .Command = dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "b-simple-app" , "--output" , dir .Join ("simple-bundle.json" ))
43- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
44- cmd .Command = dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "a-simple-app" , "--output" , dir .Join ("simple-bundle.json" ))
71+ cmd .Command = dockerCli .Command ("app" , "image" , "rm" , "a-simple-app:latest" , "b-simple-app:latest" )
4572 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
4673
47- expectedOutput := fmt . Sprintf ( expected , info . registryAddress + "/c-myapp" )
74+ expectedOutput := "REPOSITORY TAG APP NAME \n "
4875 cmd .Command = dockerCli .Command ("app" , "image" , "ls" )
4976 result := icmd .RunCmd (cmd ).Assert (t , icmd .Success )
5077 assert .Equal (t , result .Stdout (), expectedOutput )
0 commit comments