@@ -116,8 +116,8 @@ services:
116116 }
117117}
118118
119- func TestExtendBuildOverImage (t * testing.T ) {
120- _ , configV1 , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
119+ func TestExtendBuildOverImageV1 (t * testing.T ) {
120+ _ , config , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
121121parent:
122122 image: foo
123123child:
@@ -129,7 +129,24 @@ child:
129129 t .Fatal (err )
130130 }
131131
132- _ , configV2 , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
132+ parent := config ["parent" ]
133+ child := config ["child" ]
134+
135+ if parent .Image != "foo" {
136+ t .Fatal ("Invalid image" , parent .Image )
137+ }
138+
139+ if child .Build .Context != "." {
140+ t .Fatal ("Invalid build" , child .Build )
141+ }
142+
143+ if child .Image != "" {
144+ t .Fatal ("Invalid image" , child .Image )
145+ }
146+ }
147+
148+ func TestExtendBuildOverImageV2 (t * testing.T ) {
149+ _ , config , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
133150version: '2'
134151services:
135152 parent:
@@ -144,26 +161,24 @@ services:
144161 t .Fatal (err )
145162 }
146163
147- for _ , config := range []map [string ]* ServiceConfig {configV1 , configV2 } {
148- parent := config ["parent" ]
149- child := config ["child" ]
164+ parent := config ["parent" ]
165+ child := config ["child" ]
150166
151- if parent .Image != "foo" {
152- t .Fatal ("Invalid image" , parent .Image )
153- }
167+ if parent .Image != "foo" {
168+ t .Fatal ("Invalid image" , parent .Image )
169+ }
154170
155- if child .Build .Context != "." {
156- t .Fatal ("Invalid build" , child .Build )
157- }
171+ if child .Build .Context != "." {
172+ t .Fatal ("Invalid build" , child .Build )
173+ }
158174
159- if child .Image != "" {
160- t .Fatal ("Invalid image" , child .Image )
161- }
175+ if child .Image != "foo" {
176+ t .Fatal ("Invalid image" , child .Image )
162177 }
163178}
164179
165- func TestExtendImageOverBuild (t * testing.T ) {
166- _ , configV1 , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
180+ func TestExtendImageOverBuildV1 (t * testing.T ) {
181+ _ , config , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
167182parent:
168183 build: .
169184child:
@@ -175,7 +190,29 @@ child:
175190 t .Fatal (err )
176191 }
177192
178- _ , configV2 , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
193+ parent := config ["parent" ]
194+ child := config ["child" ]
195+
196+ if parent .Image != "" {
197+ t .Fatal ("Invalid image" , parent .Image )
198+ }
199+
200+ if parent .Build .Context != "." {
201+ t .Fatal ("Invalid build" , parent .Build )
202+ }
203+
204+ if child .Build .Context != "" {
205+ t .Fatal ("Invalid build" , child .Build )
206+ }
207+
208+ if child .Image != "foo" {
209+ t .Fatal ("Invalid image" , child .Image )
210+ }
211+
212+ }
213+
214+ func TestExtendImageOverBuildV2 (t * testing.T ) {
215+ _ , config , _ , _ , err := Merge (NewServiceConfigs (), nil , & NullLookup {}, "" , []byte (`
179216version: '2'
180217services:
181218 parent:
@@ -190,25 +227,23 @@ services:
190227 t .Fatal (err )
191228 }
192229
193- for _ , config := range []map [string ]* ServiceConfig {configV1 , configV2 } {
194- parent := config ["parent" ]
195- child := config ["child" ]
230+ parent := config ["parent" ]
231+ child := config ["child" ]
196232
197- if parent .Image != "" {
198- t .Fatal ("Invalid image" , parent .Image )
199- }
233+ if parent .Image != "" {
234+ t .Fatal ("Invalid image" , parent .Image )
235+ }
200236
201- if parent .Build .Context != "." {
202- t .Fatal ("Invalid build" , parent .Build )
203- }
237+ if parent .Build .Context != "." {
238+ t .Fatal ("Invalid build" , parent .Build )
239+ }
204240
205- if child .Build .Context != "" {
206- t .Fatal ("Invalid build" , child .Build )
207- }
241+ if child .Build .Context != ". " {
242+ t .Fatal ("Invalid build" , child .Build )
243+ }
208244
209- if child .Image != "foo" {
210- t .Fatal ("Invalid image" , child .Image )
211- }
245+ if child .Image != "foo" {
246+ t .Fatal ("Invalid image" , child .Image )
212247 }
213248}
214249
0 commit comments