@@ -99,6 +99,11 @@ func TestImageTag(t *testing.T) {
9999 dir := fs .NewDir (t , "" )
100100 defer dir .Remove ()
101101
102+ dockerAppImageTag := func (args ... string ) {
103+ cmdArgs := append ([]string {"app" , "image" , "tag" }, args ... )
104+ cmd .Command = dockerCli .Command (cmdArgs ... )
105+ }
106+
102107 // given a first available image
103108 cmd .Command = dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "a-simple-app" , "--output" , dir .Join ("simple-bundle.json" ))
104109 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
@@ -109,43 +114,43 @@ a-simple-app:latest simple
109114 expectImageListOutput (t , cmd , singleImageExpectation )
110115
111116 // with no argument
112- cmd . Command = dockerCli . Command ( "app" , "bundle" , "tag" )
117+ dockerAppImageTag ( )
113118 icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
114119 ExitCode : 1 ,
115120 Err : `"docker app image tag" requires exactly 2 arguments.` ,
116121 })
117122
118123 // with one argument
119- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app" )
124+ dockerAppImageTag ( "a-simple-app" )
120125 icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
121126 ExitCode : 1 ,
122127 Err : `"docker app image tag" requires exactly 2 arguments.` ,
123128 })
124129
125130 // with invalid src reference
126- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app$2" , "b-simple-app" )
131+ dockerAppImageTag ( "a-simple-app$2" , "b-simple-app" )
127132 icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
128133 ExitCode : 1 ,
129134 Err : `could not parse 'a-simple-app$2' as a valid reference: invalid reference format` ,
130135 })
131136
132137 // with invalid target reference
133- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app" , "b@simple-app" )
138+ dockerAppImageTag ( "a-simple-app" , "b@simple-app" )
134139 icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
135140 ExitCode : 1 ,
136141 Err : `could not parse 'b@simple-app' as a valid reference: invalid reference format` ,
137142 })
138143
139144 // tag image with only names
140- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app" , "b-simple-app" )
145+ dockerAppImageTag ( "a-simple-app" , "b-simple-app" )
141146 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
142147 expectImageListOutput (t , cmd , `APP IMAGE APP NAME
143148a-simple-app:latest simple
144149b-simple-app:latest simple
145150` )
146151
147152 // target tag
148- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app" , "a-simple-app:0.1" )
153+ dockerAppImageTag ( "a-simple-app" , "a-simple-app:0.1" )
149154 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
150155 expectImageListOutput (t , cmd , `APP IMAGE APP NAME
151156a-simple-app:0.1 simple
@@ -154,7 +159,7 @@ b-simple-app:latest simple
154159` )
155160
156161 // source tag
157- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app:0.1" , "c-simple-app" )
162+ dockerAppImageTag ( "a-simple-app:0.1" , "c-simple-app" )
158163 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
159164 expectImageListOutput (t , cmd , `APP IMAGE APP NAME
160165a-simple-app:0.1 simple
@@ -164,7 +169,7 @@ c-simple-app:latest simple
164169` )
165170
166171 // source and target tags
167- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app:0.1" , "b-simple-app:0.2" )
172+ dockerAppImageTag ( "a-simple-app:0.1" , "b-simple-app:0.2" )
168173 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
169174 expectImageListOutput (t , cmd , `APP IMAGE APP NAME
170175a-simple-app:0.1 simple
@@ -187,7 +192,7 @@ push-pull:latest push-pull
187192` )
188193
189194 // can be tagged to an existing tag
190- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "push-pull" , "b-simple-app:0.2" )
195+ dockerAppImageTag ( "push-pull" , "b-simple-app:0.2" )
191196 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
192197 expectImageListOutput (t , cmd , `APP IMAGE APP NAME
193198a-simple-app:0.1 simple
0 commit comments