@@ -261,35 +261,60 @@ func TestBundle(t *testing.T) {
261261 cmd .Command = dockerCli .Command ("load" , "-i" , tmpDir .Join ("cnab-app-base.tar.gz" ))
262262 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
263263
264- // Bundle the docker application package to a CNAB bundle, using the build-context.
265- cmd .Command = dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--output" , tmpDir .Join ("bundle.json" ))
266- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
267-
268- // Check the resulting CNAB bundle.json
269- golden .Assert (t , string (golden .Get (t , tmpDir .Join ("bundle.json" ))), "simple-bundle.json.golden" )
270-
271- // List the images on the build context daemon and checks the invocation image is there
272- cmd .Command = dockerCli .Command ("image" , "ls" , "--format" , "{{.Repository}}:{{.Tag}}" )
273- icmd .RunCmd (cmd ).Assert (t , icmd.Expected {ExitCode : 0 , Out : "simple:1.1.0-beta1-invoc" })
274-
275- // Copy all the files from the invocation image and check them
276- cmd .Command = dockerCli .Command ("create" , "--name" , "invocation" , "simple:1.1.0-beta1-invoc" )
277- id := strings .TrimSpace (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Stdout ())
278- cmd .Command = dockerCli .Command ("cp" , "invocation:/cnab/app/simple.dockerapp" , tmpDir .Join ("simple.dockerapp" ))
279- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
280- cmd .Command = dockerCli .Command ("rm" , "--force" , id )
281- icmd .RunCmd (cmd ).Assert (t , icmd .Success )
282-
283- appDir := filepath .Join ("testdata" , "simple" , "simple.dockerapp" )
284- manifest := fs .Expected (
285- t ,
286- fs .WithMode (0755 ),
287- fs .WithFile (internal .MetadataFileName , readFile (t , filepath .Join (appDir , internal .MetadataFileName )), fs .WithMode (0644 )),
288- fs .WithFile (internal .ComposeFileName , readFile (t , filepath .Join (appDir , internal .ComposeFileName )), fs .WithMode (0644 )),
289- fs .WithFile (internal .ParametersFileName , readFile (t , filepath .Join (appDir , internal .ParametersFileName )), fs .WithMode (0644 )),
290- )
291-
292- assert .Assert (t , fs .Equal (tmpDir .Join ("simple.dockerapp" ), manifest ))
264+ testCases := []struct {
265+ name string
266+ cmd []string
267+ invocImage string
268+ expectedBundle string
269+ }{
270+ {
271+ name : "simple-bundle" ,
272+ cmd : dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--output" , tmpDir .Join ("simple-bundle.json" )),
273+ invocImage : "simple:1.1.0-beta1-invoc" ,
274+ expectedBundle : "simple-bundle.json.golden" ,
275+ },
276+ {
277+ name : "bundle-with-tag" ,
278+ cmd : dockerCli .Command ("app" , "bundle" , filepath .Join ("testdata" , "simple" , "simple.dockerapp" ), "--tag" , "myimage:mytag" , "--output" , tmpDir .Join ("bundle-with-tag.json" )),
279+ invocImage : "myimage:mytag-invoc" ,
280+ expectedBundle : "bundle-with-tag.json.golden" ,
281+ },
282+ }
283+ for _ , tc := range testCases {
284+ t .Run (tc .name , func (t * testing.T ) {
285+ testDir := fs .NewDir (t , "" )
286+ defer testDir .Remove ()
287+
288+ // Bundle the docker application package to a CNAB bundle, using the build-context.
289+ cmd .Command = tc .cmd
290+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
291+
292+ // Check the resulting CNAB bundle.json
293+ golden .Assert (t , string (golden .Get (t , tmpDir .Join (tc .name + ".json" ))), tc .expectedBundle )
294+
295+ // List the images on the build context daemon and checks the invocation image is there
296+ cmd .Command = dockerCli .Command ("image" , "ls" , "--format" , "{{.Repository}}:{{.Tag}}" )
297+ icmd .RunCmd (cmd ).Assert (t , icmd.Expected {ExitCode : 0 , Out : tc .invocImage })
298+
299+ // Copy all the files from the invocation image and check them
300+ cmd .Command = dockerCli .Command ("create" , "--name" , "invocation" , tc .invocImage )
301+ id := strings .TrimSpace (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Stdout ())
302+ cmd .Command = dockerCli .Command ("cp" , "invocation:/cnab/app/simple.dockerapp" , testDir .Join ("simple.dockerapp" ))
303+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
304+ cmd .Command = dockerCli .Command ("rm" , "--force" , id )
305+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
306+
307+ appDir := filepath .Join ("testdata" , "simple" , "simple.dockerapp" )
308+ manifest := fs .Expected (
309+ t ,
310+ fs .WithMode (0755 ),
311+ fs .WithFile (internal .MetadataFileName , readFile (t , filepath .Join (appDir , internal .MetadataFileName )), fs .WithMode (0644 )),
312+ fs .WithFile (internal .ComposeFileName , readFile (t , filepath .Join (appDir , internal .ComposeFileName )), fs .WithMode (0644 )),
313+ fs .WithFile (internal .ParametersFileName , readFile (t , filepath .Join (appDir , internal .ParametersFileName )), fs .WithMode (0644 )),
314+ )
315+ assert .Assert (t , fs .Equal (testDir .Join ("simple.dockerapp" ), manifest ))
316+ })
317+ }
293318}
294319
295320func TestDockerAppLifecycle (t * testing.T ) {
0 commit comments