chore: add failure test case for empty generator

This commit is contained in:
Mauren Berti
2024-01-29 22:56:59 -05:00
parent ca8d629230
commit 6c1fea79ed
2 changed files with 22 additions and 2 deletions

View File

@@ -46,7 +46,7 @@ configMapGenerator:
name: test-cm
`,
Args: []string{"test-cm2", "--from-literal=test-key=test-value"},
ExpectedErrorMsg: "unable to find ConfigMap with name '\"test-cm2\"'",
ExpectedErrorMsg: "unable to find ConfigMap with name \"test-cm2\"",
},
{
Name: "fails validation because no attributes are being changed",
@@ -76,6 +76,16 @@ configMapGenerator:
Args: []string{"test-cm", "--from-literal=value"},
ExpectedErrorMsg: "literal values must be specified in the key=value format",
},
{
Name: "fails when the configMapGenerator field has no items",
KustomizationFileContent: `
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator: []
`,
Args: []string{"test-cm", "--from-literal=value"},
ExpectedErrorMsg: "unable to find ConfigMap with name \"test-cm\"",
},
}
for _, tc := range testCases {

View File

@@ -52,7 +52,7 @@ secretGenerator:
type: Opaque
`,
Args: []string{"test-secret2", "--from-literal=key3=val2"},
ExpectedErrorMsg: "unable to find Secret with name '\"test-secret2\"'",
ExpectedErrorMsg: "unable to find Secret with name \"test-secret2\"",
},
{
Name: "fails validation because no attributes are being changed",
@@ -83,6 +83,16 @@ secretGenerator:
Args: []string{"test-secret", "--from-literal=value"},
ExpectedErrorMsg: "literal values must be specified in the key=value format",
},
{
Name: "fails when the secretGenerator field has no items",
KustomizationFileContent: `
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
secretGenerator: []
`,
Args: []string{"test-secret", "--from-literal=value"},
ExpectedErrorMsg: "unable to find Secret with name \"test-secret\"",
},
}
for _, tc := range testCases {