From 46b3cd210985f2d7342dd31a0de74f767a5bf456 Mon Sep 17 00:00:00 2001 From: natasha41575 Date: Mon, 8 Nov 2021 12:21:45 -0800 Subject: [PATCH] modify edit test for null replacements fields --- .../commands/edit/add/addresource_test.go | 25 +++++++++++++++++-- .../commands/internal/testutils/testutils.go | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/kustomize/commands/edit/add/addresource_test.go b/kustomize/commands/edit/add/addresource_test.go index efc144224..1e9679de9 100644 --- a/kustomize/commands/edit/add/addresource_test.go +++ b/kustomize/commands/edit/add/addresource_test.go @@ -33,8 +33,29 @@ func TestAddResourceHappyPath(t *testing.T) { assert.NoError(t, cmd.RunE(cmd, args)) content, err := testutils_test.ReadTestKustomization(fSys) assert.NoError(t, err) - assert.Contains(t, string(content), resourceFileName) - assert.Contains(t, string(content), resourceFileName+"another") + assert.Equal(t, string(content), `apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: some-prefix +nameSuffix: some-suffix +# Labels to add to all objects and selectors. +# These labels would also be used to form the selector for apply --prune +# Named differently than “labels” to avoid confusion with metadata for this object +commonLabels: + app: helloworld +commonAnnotations: + note: This is an example annotation +resources: +- myWonderfulResource.yaml +- myWonderfulResource.yamlanother +#- service.yaml +#- ../some-dir/ +# There could also be configmaps in Base, which would make these overlays +# There could be secrets in Base, if just using a fork/rebase workflow +replacements: +- path: replacement.yaml + source: null + targets: null +`) } func TestAddResourceAlreadyThere(t *testing.T) { diff --git a/kustomize/commands/internal/testutils/testutils.go b/kustomize/commands/internal/testutils/testutils.go index d25c03b97..c5c8359a3 100644 --- a/kustomize/commands/internal/testutils/testutils.go +++ b/kustomize/commands/internal/testutils/testutils.go @@ -28,6 +28,8 @@ resources: [] configMapGenerator: [] # There could be secrets in Base, if just using a fork/rebase workflow secretGenerator: [] +replacements: + - path: replacement.yaml ` )