@@ -341,16 +341,8 @@ func TestDockerAppLifecycle(t *testing.T) {
341341
342342 // Install a Docker Application Package with an existing failed installation is fine
343343 cmd .Command = dockerCli .Command ("app" , "run" , appName , "--name" , appName )
344- checkContains (t , icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (),
345- []string {
346- fmt .Sprintf ("WARNING: installing over previously failed installation %q" , appName ),
347- fmt .Sprintf ("Creating network %s_back" , appName ),
348- fmt .Sprintf ("Creating network %s_front" , appName ),
349- fmt .Sprintf ("Creating service %s_db" , appName ),
350- fmt .Sprintf ("Creating service %s_api" , appName ),
351- fmt .Sprintf ("Creating service %s_web" , appName ),
352- })
353- assertAppLabels (t , & cmd , appName , "db" )
344+ checkContains (t , icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), expectedAppRunOutput (appName , true ))
345+ assertAppDbLabels (t , & cmd , appName )
354346
355347 // List the installed application
356348 cmd .Command = dockerCli .Command ("app" , "ls" )
@@ -375,21 +367,64 @@ func TestDockerAppLifecycle(t *testing.T) {
375367 fmt .Sprintf ("Updating service %s_api" , appName ),
376368 fmt .Sprintf ("Updating service %s_web" , appName ),
377369 })
378- assertAppLabels (t , & cmd , appName , "db" )
370+ assertAppDbLabels (t , & cmd , appName )
379371
380372 // Uninstall the application
381373 cmd .Command = dockerCli .Command ("app" , "rm" , appName )
382- checkContains (t , icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (),
383- []string {
384- fmt .Sprintf ("Removing service %s_api" , appName ),
385- fmt .Sprintf ("Removing service %s_db" , appName ),
386- fmt .Sprintf ("Removing service %s_web" , appName ),
387- fmt .Sprintf ("Removing network %s_front" , appName ),
388- fmt .Sprintf ("Removing network %s_back" , appName ),
389- })
374+ checkContains (t , icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), expectedAppRmOutput (appName ))
375+ })
376+ }
377+
378+ func TestDockerAppLifecycleMultiRm (t * testing.T ) {
379+ runWithDindSwarmAndRegistry (t , func (info dindSwarmAndRegistryInfo ) {
380+ cmd := info .configuredCmd
381+ appName := strings .ToLower (strings .Replace (t .Name (), "/" , "_" , 1 ))
382+ tmpDir := fs .NewDir (t , appName )
383+ defer tmpDir .Remove ()
384+
385+ cmd .Command = dockerCli .Command ("app" , "build" , "--tag" , appName , "testdata/simple" )
386+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
387+
388+ // Install multiple applications
389+ cmd .Command = dockerCli .Command ("app" , "run" , appName , "--name" , appName )
390+ checkContains (t , icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), expectedAppRunOutput (appName , false ))
391+ assertAppDbLabels (t , & cmd , appName )
392+ appName2 := appName + "2"
393+ cmd .Command = dockerCli .Command ("app" , "run" , appName , "--name" , appName2 , "--set" , "web_port=8083" )
394+ checkContains (t , icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), expectedAppRunOutput (appName2 , false ))
395+ assertAppDbLabels (t , & cmd , appName2 )
396+
397+ // Uninstall multiple applications
398+ cmd .Command = dockerCli .Command ("app" , "rm" , appName , appName2 )
399+ checkContains (t , icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), append (expectedAppRmOutput (appName ), expectedAppRmOutput (appName2 )... ))
390400 })
391401}
392402
403+ func expectedAppRunOutput (appName string , prevFailed bool ) []string {
404+ expected := []string {}
405+ if prevFailed {
406+ expected = append (expected , fmt .Sprintf ("WARNING: installing over previously failed installation %q" , appName ))
407+ }
408+ expected = append (expected ,
409+ fmt .Sprintf ("Creating network %s_back" , appName ),
410+ fmt .Sprintf ("Creating network %s_front" , appName ),
411+ fmt .Sprintf ("Creating service %s_db" , appName ),
412+ fmt .Sprintf ("Creating service %s_api" , appName ),
413+ fmt .Sprintf ("Creating service %s_web" , appName ),
414+ )
415+ return expected
416+ }
417+
418+ func expectedAppRmOutput (appName string ) []string {
419+ return []string {
420+ fmt .Sprintf ("Removing service %s_api" , appName ),
421+ fmt .Sprintf ("Removing service %s_db" , appName ),
422+ fmt .Sprintf ("Removing service %s_web" , appName ),
423+ fmt .Sprintf ("Removing network %s_front" , appName ),
424+ fmt .Sprintf ("Removing network %s_back" , appName ),
425+ }
426+ }
427+
393428func TestCredentials (t * testing.T ) {
394429 credSet := & credentials.CredentialSet {
395430 Name : "test-creds" ,
@@ -499,8 +534,8 @@ func TestCredentials(t *testing.T) {
499534 })
500535}
501536
502- func assertAppLabels (t * testing.T , cmd * icmd.Cmd , appName , containerName string ) {
503- cmd .Command = dockerCli .Command ("inspect" , fmt .Sprintf ("%s_%s " , appName , containerName ))
537+ func assertAppDbLabels (t * testing.T , cmd * icmd.Cmd , appName string ) {
538+ cmd .Command = dockerCli .Command ("inspect" , fmt .Sprintf ("%s_db " , appName ))
504539 checkContains (t , icmd .RunCmd (* cmd ).Assert (t , icmd .Success ).Combined (),
505540 []string {
506541 fmt .Sprintf (`"%s": "%s"` , internal .LabelAppNamespace , appName ),
0 commit comments