mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 17:34:21 +00:00
update test add KustomizationFile
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
testutils_test "sigs.k8s.io/kustomize/kustomize/v5/commands/internal/testutils"
|
||||
"sigs.k8s.io/kustomize/kyaml/filesys"
|
||||
)
|
||||
@@ -51,19 +52,19 @@ func TestAddComponentAlreadyThere(t *testing.T) {
|
||||
assert.NoError(t, cmd.RunE(cmd, args))
|
||||
}
|
||||
|
||||
// Test for trying to add the kustomization.yaml file itself for resources.
|
||||
// This adding operation is not allowed.
|
||||
func TestAddKustomizationFileAsComponent(t *testing.T) {
|
||||
fSys := filesys.MakeEmptyDirInMemory()
|
||||
err := fSys.WriteFile(componentFileName, []byte(componentFileContent))
|
||||
require.NoError(t, err)
|
||||
testutils_test.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddComponent(fSys)
|
||||
args := []string{componentFileName}
|
||||
args := []string{konfig.DefaultKustomizationFileName()}
|
||||
require.NoError(t, cmd.RunE(cmd, args))
|
||||
|
||||
content, err := testutils_test.ReadTestKustomization(fSys)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, string(content), componentFileName)
|
||||
assert.NotContains(t, string(content), konfig.DefaultKustomizationFileName())
|
||||
}
|
||||
|
||||
func TestAddComponentNoArgs(t *testing.T) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
testutils_test "sigs.k8s.io/kustomize/kustomize/v5/commands/internal/testutils"
|
||||
"sigs.k8s.io/kustomize/kyaml/filesys"
|
||||
)
|
||||
@@ -70,20 +71,20 @@ func TestAddResourceAlreadyThere(t *testing.T) {
|
||||
assert.NoError(t, cmd.RunE(cmd, args))
|
||||
}
|
||||
|
||||
// Test for trying to add the kustomization.yaml file itself for resources.
|
||||
// This adding operation is not allowed.
|
||||
func TestAddKustomizationFileAsResource(t *testing.T) {
|
||||
fSys := filesys.MakeEmptyDirInMemory()
|
||||
err := fSys.WriteFile(resourceFileName, []byte(resourceFileContent))
|
||||
require.NoError(t, err)
|
||||
testutils_test.WriteTestKustomization(fSys)
|
||||
|
||||
cmd := newCmdAddResource(fSys)
|
||||
args := []string{resourceFileName}
|
||||
args := []string{konfig.DefaultKustomizationFileName()}
|
||||
assert.NoError(t, cmd.RunE(cmd, args))
|
||||
|
||||
content, err := testutils_test.ReadTestKustomization(fSys)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Contains(t, string(content), resourceFileName)
|
||||
assert.NotContains(t, string(content), konfig.DefaultKustomizationFileName())
|
||||
}
|
||||
|
||||
func TestAddResourceNoArgs(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user