@@ -116,8 +116,8 @@ services:
116
116
}
117
117
}
118
118
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 (`
121
121
parent:
122
122
image: foo
123
123
child:
@@ -129,7 +129,24 @@ child:
129
129
t .Fatal (err )
130
130
}
131
131
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 (`
133
150
version: '2'
134
151
services:
135
152
parent:
@@ -144,26 +161,24 @@ services:
144
161
t .Fatal (err )
145
162
}
146
163
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" ]
150
166
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
+ }
154
170
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
+ }
158
174
159
- if child .Image != "" {
160
- t .Fatal ("Invalid image" , child .Image )
161
- }
175
+ if child .Image != "foo" {
176
+ t .Fatal ("Invalid image" , child .Image )
162
177
}
163
178
}
164
179
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 (`
167
182
parent:
168
183
build: .
169
184
child:
@@ -175,7 +190,29 @@ child:
175
190
t .Fatal (err )
176
191
}
177
192
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 (`
179
216
version: '2'
180
217
services:
181
218
parent:
@@ -190,25 +227,23 @@ services:
190
227
t .Fatal (err )
191
228
}
192
229
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" ]
196
232
197
- if parent .Image != "" {
198
- t .Fatal ("Invalid image" , parent .Image )
199
- }
233
+ if parent .Image != "" {
234
+ t .Fatal ("Invalid image" , parent .Image )
235
+ }
200
236
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
+ }
204
240
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
+ }
208
244
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 )
212
247
}
213
248
}
214
249
0 commit comments