@@ -99,6 +99,11 @@ func TestImageTag(t *testing.T) {
99
99
dir := fs .NewDir (t , "" )
100
100
defer dir .Remove ()
101
101
102
+ dockerAppImageTag := func (args ... string ) {
103
+ cmdArgs := append ([]string {"app" , "image" , "tag" }, args ... )
104
+ cmd .Command = dockerCli .Command (cmdArgs ... )
105
+ }
106
+
102
107
// given a first available image
103
108
cmd .Command = dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "a-simple-app" , "--output" , dir .Join ("simple-bundle.json" ))
104
109
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
@@ -109,43 +114,43 @@ a-simple-app:latest simple
109
114
expectImageListOutput (t , cmd , singleImageExpectation )
110
115
111
116
// with no argument
112
- cmd . Command = dockerCli . Command ( "app" , "bundle" , "tag" )
117
+ dockerAppImageTag ( )
113
118
icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
114
119
ExitCode : 1 ,
115
120
Err : `"docker app image tag" requires exactly 2 arguments.` ,
116
121
})
117
122
118
123
// with one argument
119
- cmd . Command = dockerCli . Command ( "app" , "image" , "tag" , "a-simple-app" )
124
+ dockerAppImageTag ( "a-simple-app" )
120
125
icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
121
126
ExitCode : 1 ,
122
127
Err : `"docker app image tag" requires exactly 2 arguments.` ,
123
128
})
124
129
125
130
// 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" )
127
132
icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
128
133
ExitCode : 1 ,
129
134
Err : `could not parse 'a-simple-app$2' as a valid reference: invalid reference format` ,
130
135
})
131
136
132
137
// 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" )
134
139
icmd .RunCmd (cmd ).Assert (t , icmd.Expected {
135
140
ExitCode : 1 ,
136
141
Err : `could not parse 'b@simple-app' as a valid reference: invalid reference format` ,
137
142
})
138
143
139
144
// 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" )
141
146
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
142
147
expectImageListOutput (t , cmd , `APP IMAGE APP NAME
143
148
a-simple-app:latest simple
144
149
b-simple-app:latest simple
145
150
` )
146
151
147
152
// 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" )
149
154
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
150
155
expectImageListOutput (t , cmd , `APP IMAGE APP NAME
151
156
a-simple-app:0.1 simple
@@ -154,7 +159,7 @@ b-simple-app:latest simple
154
159
` )
155
160
156
161
// 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" )
158
163
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
159
164
expectImageListOutput (t , cmd , `APP IMAGE APP NAME
160
165
a-simple-app:0.1 simple
@@ -164,7 +169,7 @@ c-simple-app:latest simple
164
169
` )
165
170
166
171
// 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" )
168
173
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
169
174
expectImageListOutput (t , cmd , `APP IMAGE APP NAME
170
175
a-simple-app:0.1 simple
@@ -187,7 +192,7 @@ push-pull:latest push-pull
187
192
` )
188
193
189
194
// 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" )
191
196
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
192
197
expectImageListOutput (t , cmd , `APP IMAGE APP NAME
193
198
a-simple-app:0.1 simple
0 commit comments