diff --git a/kustomize/commands/edit/set/setconfigmap_test.go b/kustomize/commands/edit/set/setconfigmap_test.go index cabe5668a..7f9693380 100644 --- a/kustomize/commands/edit/set/setconfigmap_test.go +++ b/kustomize/commands/edit/set/setconfigmap_test.go @@ -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 { diff --git a/kustomize/commands/edit/set/setsecret_test.go b/kustomize/commands/edit/set/setsecret_test.go index c9207d8ab..bb27c8d17 100644 --- a/kustomize/commands/edit/set/setsecret_test.go +++ b/kustomize/commands/edit/set/setsecret_test.go @@ -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 {