Skip to content

Commit c9f500c

Browse files
add another resource for making sure an existing resource isn't affeced by a generator
1 parent 71a7a7d commit c9f500c

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

api/krusty/fnplugin_test.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,16 @@ func TestFnContainerGenerator(t *testing.T) {
507507
skipIfNoDocker(t)
508508
th := kusttest_test.MakeHarness(t)
509509
o := th.MakeOptionsPluginsEnabled()
510-
fSys := filesys.MakeFsOnDisk()
511-
b := MakeKustomizer(&o)
512510
tmpDir, err := filesys.NewTmpConfirmedDir()
513511
assert.NoError(t, err)
514-
assert.NoError(t, fSys.WriteFile(filepath.Join(tmpDir.String(), "kustomization.yaml"), []byte(`
512+
th.WriteK(tmpDir.String(), `
513+
resources:
514+
- deployment.yaml
515515
generators:
516516
- project-service-set.yaml
517-
`)))
518-
assert.NoError(t, fSys.WriteFile(filepath.Join(tmpDir.String(), "project-service-set.yaml"), []byte(`
517+
`)
518+
// Create generator config
519+
th.WriteF(filepath.Join(tmpDir.String(), "project-service-set.yaml"), `
519520
apiVersion: blueprints.cloud.google.com/v1alpha1
520521
kind: ProjectServiceSet
521522
metadata:
@@ -528,12 +529,23 @@ spec:
528529
services:
529530
- compute.googleapis.com
530531
projectID: foo
531-
`)))
532-
m, err := b.Run(fSys, tmpDir.String())
533-
assert.NoError(t, err)
532+
`)
533+
// Create another resource just to make sure everything is added
534+
th.WriteF(filepath.Join(tmpDir.String(), "deployment.yaml"), `
535+
apiVersion: apps/v1
536+
kind: Deployment
537+
metadata:
538+
name: foo
539+
`)
540+
m := th.Run(tmpDir.String(), o)
534541
actual, err := m.AsYaml()
535542
assert.NoError(t, err)
536-
assert.Equal(t, `apiVersion: serviceusage.cnrm.cloud.google.com/v1beta1
543+
assert.Equal(t, `apiVersion: apps/v1
544+
kind: Deployment
545+
metadata:
546+
name: foo
547+
---
548+
apiVersion: serviceusage.cnrm.cloud.google.com/v1beta1
537549
kind: Service
538550
metadata:
539551
annotations:

0 commit comments

Comments
 (0)