@@ -96,7 +96,6 @@ var deploy = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deploy
96
96
var cmap = schema.GroupVersionKind {Version : "v1" , Kind : "ConfigMap" }
97
97
var secret = schema.GroupVersionKind {Version : "v1" , Kind : "Secret" }
98
98
var ns = schema.GroupVersionKind {Version : "v1" , Kind : "Namespace" }
99
- var svc = schema.GroupVersionKind {Version : "v1" , Kind : "Service" }
100
99
101
100
func TestResources1 (t * testing.T ) {
102
101
expected := resmap.ResMap {
@@ -227,153 +226,6 @@ func TestResourceNotFound(t *testing.T) {
227
226
}
228
227
}
229
228
230
- func TestRawResources1 (t * testing.T ) {
231
- expected := resmap.ResMap {
232
- resource .NewResId (deploy , "dply1" ): resource .NewResourceFromMap (
233
- map [string ]interface {}{
234
- "apiVersion" : "apps/v1" ,
235
- "kind" : "Deployment" ,
236
- "metadata" : map [string ]interface {}{
237
- "name" : "dply1" ,
238
- },
239
- }),
240
- resource .NewResId (ns , "ns1" ): resource .NewResourceFromMap (
241
- map [string ]interface {}{
242
- "apiVersion" : "v1" ,
243
- "kind" : "Namespace" ,
244
- "metadata" : map [string ]interface {}{
245
- "name" : "ns1" ,
246
- },
247
- }),
248
- }
249
- l := makeLoader1 (t )
250
- app , err := NewApplication (l , fs .MakeFakeFS ())
251
- if err != nil {
252
- t .Fatalf ("Unexpected construction error %v" , err )
253
- }
254
- actual , err := app .MakeUncustomizedResMap ()
255
- if err != nil {
256
- t .Fatalf ("Unexpected RawResources error %v" , err )
257
- }
258
-
259
- if err := expected .ErrorIfNotEqual (actual ); err != nil {
260
- t .Fatalf ("unexpected inequality: %v" , err )
261
- }
262
- }
263
-
264
- const (
265
- kustomizationContentBase = `
266
- namePrefix: foo-
267
- commonLabels:
268
- app: banana
269
- resources:
270
- - deployment.yaml
271
- `
272
- kustomizationContentOverlay = `
273
- commonLabels:
274
- env: staging
275
- resources:
276
- - service.yaml
277
- bases:
278
- - base
279
- `
280
- serviceContent = `apiVersion: v1
281
- kind: Service
282
- metadata:
283
- name: svc
284
- spec:
285
- type: LoadBalancer
286
- `
287
- )
288
-
289
- func makeLoader2 (t * testing.T ) loader.Loader {
290
- ldr := loadertest .NewFakeLoader ("/testpath" )
291
- err := ldr .AddFile ("/testpath/" + constants .KustomizationFileName , []byte (kustomizationContentOverlay ))
292
- if err != nil {
293
- t .Fatal (err )
294
- }
295
- err = ldr .AddFile ("/testpath/service.yaml" , []byte (serviceContent ))
296
- if err != nil {
297
- t .Fatalf ("Failed to setup fake ldr." )
298
- }
299
- err = ldr .AddDirectory ("/testpath/base" )
300
- if err != nil {
301
- t .Fatalf ("Failed to setup fake ldr." )
302
- }
303
- err = ldr .AddFile ("/testpath/base/" + constants .KustomizationFileName , []byte (kustomizationContentBase ))
304
- if err != nil {
305
- t .Fatalf ("Failed to setup fake ldr." )
306
- }
307
- err = ldr .AddFile ("/testpath/base/deployment.yaml" , []byte (deploymentContent ))
308
- if err != nil {
309
- t .Fatalf ("Failed to setup fake ldr." )
310
- }
311
- return ldr
312
- }
313
-
314
- // TODO: This test covers incorrect behavior; it should not pass.
315
- // It asks for raw resources. The Service resource is returned in raw form,
316
- // but the resources in the base are modified to have the banana label,
317
- // the 'foo' name prefix, etc. This method exists only to support the
318
- // diff command comparing customized to non-customized resources;
319
- // perhaps it's not worth supporting the command.
320
- func TestRawResources2 (t * testing.T ) {
321
- expected := resmap.ResMap {
322
- resource .NewResIdWithPrefix (deploy , "dply1" , "foo-" ): resource .NewResourceFromMap (
323
- map [string ]interface {}{
324
- "apiVersion" : "apps/v1" ,
325
- "kind" : "Deployment" ,
326
- "metadata" : map [string ]interface {}{
327
- "name" : "foo-dply1" ,
328
- "labels" : map [string ]interface {}{
329
- "app" : "banana" ,
330
- },
331
- },
332
- "spec" : map [string ]interface {}{
333
- "selector" : map [string ]interface {}{
334
- "matchLabels" : map [string ]interface {}{
335
- "app" : "banana" ,
336
- },
337
- },
338
- "template" : map [string ]interface {}{
339
- "metadata" : map [string ]interface {}{
340
- "labels" : map [string ]interface {}{
341
- "app" : "banana" ,
342
- },
343
- },
344
- },
345
- },
346
- }),
347
- resource .NewResId (svc , "svc" ): resource .NewResourceFromMap (
348
- map [string ]interface {}{
349
- "apiVersion" : "v1" ,
350
- "kind" : "Service" ,
351
- "metadata" : map [string ]interface {}{
352
- "name" : "svc" ,
353
- },
354
- "spec" : map [string ]interface {}{
355
- "type" : "LoadBalancer" ,
356
- },
357
- }),
358
- }
359
- l := makeLoader2 (t )
360
- app , err := NewApplication (l , fs .MakeFakeFS ())
361
- if err != nil {
362
- t .Fatalf ("Unexpected construction error %v" , err )
363
- }
364
- actual , err := app .MakeUncustomizedResMap ()
365
- if err != nil {
366
- t .Fatalf ("Unexpected RawResources error %v" , err )
367
- }
368
-
369
- if err := expected .ErrorIfNotEqual (actual ); err != nil {
370
- t .Fatalf ("unexpected inequality: %v" , err )
371
- }
372
- if ! loadertest .CleanupCalled {
373
- t .Fatalf ("Cleanup should be called" )
374
- }
375
- }
376
-
377
229
func TestSecretTimeout (t * testing.T ) {
378
230
l := loadertest .NewFakeLoader ("/testpath" )
379
231
err := l .AddFile ("/testpath/" + constants .KustomizationFileName , []byte (kustomizationContent2 ))
0 commit comments