Skip to content

Commit

Permalink
update testcase.
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-chenzz committed Feb 4, 2024
1 parent de479e1 commit 09b4bc5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions kustomize/commands/edit/add/addreplacement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}
}

Expand Down

0 comments on commit 09b4bc5

Please sign in to comment.