From 09b4bc514a7874768aba8cbcd322f52fb5b86038 Mon Sep 17 00:00:00 2001 From: charles-chenzz Date: Thu, 25 Jan 2024 17:44:39 +0600 Subject: [PATCH] update testcase. --- .../commands/edit/add/addreplacement_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kustomize/commands/edit/add/addreplacement_test.go b/kustomize/commands/edit/add/addreplacement_test.go index 13754287df4..042cf8c2f93 100644 --- a/kustomize/commands/edit/add/addreplacement_test.go +++ b/kustomize/commands/edit/add/addreplacement_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "sigs.k8s.io/kustomize/kustomize/v5/commands/internal/kustfile" testutils_test "sigs.k8s.io/kustomize/kustomize/v5/commands/internal/testutils" "sigs.k8s.io/kustomize/kyaml/filesys" ) @@ -29,10 +30,19 @@ func TestAddReplacementWithFilePath(t *testing.T) { } cmd.SetArgs(args) assert.NoError(t, cmd.Execute()) - content, err := testutils_test.ReadTestKustomization(fSys) + _, err = testutils_test.ReadTestKustomization(fSys) assert.NoError(t, err) - for i := 1; i < len(args); i += 2 { - assert.Contains(t, string(content), args[i]) + + kf, err := kustfile.NewKustomizationFile(fSys) + require.NoError(t, err) + + kustomization, err := kf.Read() + require.NoError(t, err) + + expectedPath := []string{replaceFileName, patchFileName} + + for k, replacement := range kustomization.Replacements { + require.Equal(t, expectedPath[k], replacement.Path) } }