Skip to content

Commit

Permalink
update testcase.
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-chenzz committed Jan 25, 2024
1 parent de479e1 commit 45a834b
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 @@ -4,6 +4,7 @@
package add

import (
"sigs.k8s.io/kustomize/kustomize/v5/commands/internal/kustfile"
"testing"

"github.com/stretchr/testify/assert"
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 45a834b

Please sign in to comment.