@@ -39,6 +39,7 @@ func TestComposeBuild(t *testing.T) {
3939 // Make sure we shard the image name to something unique to the test to avoid conflicts with other tests
4040 imageSvc0 := data .Identifier ("svc0" )
4141 imageSvc1 := data .Identifier ("svc1" )
42+ imageSvc2 := data .Identifier ("svc2" )
4243
4344 // We are not going to run them, so, ports conflicts should not matter here
4445 dockerComposeYAML := fmt .Sprintf (`
@@ -51,14 +52,21 @@ services:
5152 svc1:
5253 build: .
5354 image: %s
54- ` , imageSvc0 , imageSvc1 )
55+ svc2:
56+ image: %s
57+ build:
58+ context: .
59+ dockerfile_inline: |
60+ FROM %s
61+ ` , imageSvc0 , imageSvc1 , imageSvc2 , testutil .CommonImage )
5562
5663 data .Temp ().Save (dockerComposeYAML , "compose.yaml" )
5764 data .Temp ().Save (dockerfile , "Dockerfile" )
5865
5966 data .Labels ().Set ("composeYaml" , data .Temp ().Path ("compose.yaml" ))
6067 data .Labels ().Set ("imageSvc0" , imageSvc0 )
6168 data .Labels ().Set ("imageSvc1" , imageSvc1 )
69+ data .Labels ().Set ("imageSvc2" , imageSvc2 )
6270 }
6371
6472 testCase .SubTests = []* test.Case {
@@ -76,22 +84,41 @@ services:
7684 Output : expect .All (
7785 expect .Contains (data .Labels ().Get ("imageSvc0" )),
7886 expect .DoesNotContain (data .Labels ().Get ("imageSvc1" )),
87+ expect .DoesNotContain (data .Labels ().Get ("imageSvc2" )),
88+ ),
89+ }
90+ },
91+ },
92+ {
93+ Description : "build svc2" ,
94+ NoParallel : true ,
95+ Setup : func (data test.Data , helpers test.Helpers ) {
96+ helpers .Ensure ("compose" , "-f" , data .Labels ().Get ("composeYaml" ), "build" , "svc2" )
97+ },
98+
99+ Command : test .Command ("images" ),
100+
101+ Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
102+ return & test.Expected {
103+ Output : expect .All (
104+ expect .Contains (data .Labels ().Get ("imageSvc2" )),
105+ expect .DoesNotContain (data .Labels ().Get ("imageSvc1" )),
79106 ),
80107 }
81108 },
82109 },
83110 {
84- Description : "build svc0 and svc1" ,
111+ Description : "build svc0, svc1, svc2 " ,
85112 NoParallel : true ,
86113 Setup : func (data test.Data , helpers test.Helpers ) {
87- helpers .Ensure ("compose" , "-f" , data .Labels ().Get ("composeYaml" ), "build" , "svc0" , "svc1" )
114+ helpers .Ensure ("compose" , "-f" , data .Labels ().Get ("composeYaml" ), "build" , "svc0" , "svc1" , "svc2" )
88115 },
89116
90117 Command : test .Command ("images" ),
91118
92119 Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
93120 return & test.Expected {
94- Output : expect .Contains (data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" )),
121+ Output : expect .Contains (data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" ), data . Labels (). Get ( "imageSvc2" ) ),
95122 }
96123 },
97124 },
@@ -122,7 +149,7 @@ services:
122149
123150 testCase .Cleanup = func (data test.Data , helpers test.Helpers ) {
124151 if data .Labels ().Get ("imageSvc0" ) != "" {
125- helpers .Anyhow ("rmi" , data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" ))
152+ helpers .Anyhow ("rmi" , data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" ), data . Labels (). Get ( "imageSvc2" ) )
126153 }
127154 }
128155
0 commit comments