@@ -377,6 +377,46 @@ services:
377377	base .ComposeCmd ("-f" , comp .YAMLFullPath (), "down" ).AssertOK ()
378378}
379379
380+ func  TestComposeUpNoRecreateDependencies (t  * testing.T ) {
381+ 	base  :=  testutil .NewBase (t )
382+ 
383+ 	var  dockerComposeYAML  =  fmt .Sprintf (` 
384+ services: 
385+   foo: 
386+     image: %s 
387+     command: "sleep infinity" 
388+   bar: 
389+     image: %s 
390+     command: "sleep infinity" 
391+     depends_on: 
392+       - foo 
393+ ` , testutil .CommonImage , testutil .CommonImage )
394+ 
395+ 	comp  :=  testutil .NewComposeDir (t , dockerComposeYAML )
396+ 	defer  comp .CleanUp ()
397+ 	projectName  :=  comp .ProjectName ()
398+ 	t .Logf ("projectName=%q" , projectName )
399+ 
400+ 	base .ComposeCmd ("-f" , comp .YAMLFullPath (), "up" , "-d" , "foo" ).AssertOK ()
401+ 	defer  base .ComposeCmd ("-f" , comp .YAMLFullPath (), "down" , "-v" ).Run ()
402+ 
403+ 	fooName  :=  serviceparser .DefaultContainerName (projectName , "foo" , "1" )
404+ 	id1Cmd  :=  base .Cmd ("inspect" , fooName , "--format" , "{{.Id}}" )
405+ 	id1Res  :=  id1Cmd .Run ()
406+ 	out1  :=  strings .TrimSpace (id1Res .Stdout ())
407+ 	assert .Assert (id1Cmd .Base .T , id1Res .ExitCode  ==  0 , id1Res .Stdout ()+ id1Res .Stderr ())
408+ 
409+ 	// Bring up dependent service; ensure foo is not recreated (ID unchanged) 
410+ 	base .ComposeCmd ("-f" , comp .YAMLFullPath (), "up" , "-d" , "bar" ).AssertOK ()
411+ 
412+ 	id2Cmd  :=  base .Cmd ("inspect" , fooName , "--format" , "{{.Id}}" )
413+ 	id2Res  :=  id2Cmd .Run ()
414+ 	out2  :=  strings .TrimSpace (id2Res .Stdout ())
415+ 	assert .Assert (id2Cmd .Base .T , id2Res .ExitCode  ==  0 , id2Res .Stdout ()+ id2Res .Stderr ())
416+ 
417+ 	assert .Equal (base .T , out1 , out2 )
418+ }
419+ 
380420func  TestComposeUpWithExternalNetwork (t  * testing.T ) {
381421	testCase  :=  nerdtest .Setup ()
382422
0 commit comments