mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Add test for issue 3489 and improve error messages.
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/internal/plugins/builtinconfig"
|
||||
"sigs.k8s.io/kustomize/api/provider"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
@@ -518,7 +520,27 @@ func TestNameReferenceUnhappyRun(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}).ResMap(),
|
||||
expectedErr: "cannot find field 'name' in node"},
|
||||
// TODO(#3304): DECISION - kyaml better; not a bug.
|
||||
expectedErr: konfig.IfApiMachineryElseKyaml(
|
||||
`updating name reference in 'rules/resourceNames' field of `+
|
||||
`'rbac.authorization.k8s.io_v1_ClusterRole|~X|cr'`+
|
||||
`: considering field 'rules/resourceNames' of object
|
||||
{"apiVersion": "rbac.authorization.k8s.io/v1", "kind": "ClusterRole", "metadata": {
|
||||
"name": "cr"}, "rules": [{"resourceNames": {"foo": "bar"}, "resources": ["secrets"]}]}
|
||||
: visit traversal on path: [resourceNames]: no 'name' field in node`,
|
||||
`updating name reference in 'rules/resourceNames' field of `+
|
||||
`'rbac.authorization.k8s.io_v1_ClusterRole|~X|cr'`+
|
||||
`: considering field 'rules/resourceNames' of object
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: cr
|
||||
rules:
|
||||
- resourceNames:
|
||||
foo: bar
|
||||
resources:
|
||||
- secrets
|
||||
: visit traversal on path: [resourceNames]: no 'name' field in node`)},
|
||||
}
|
||||
|
||||
nrt := newNameReferenceTransformer(builtinconfig.MakeDefaultConfig().NameReference)
|
||||
@@ -529,7 +551,7 @@ func TestNameReferenceUnhappyRun(t *testing.T) {
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), test.expectedErr) {
|
||||
t.Fatalf("Incorrect error.\nExpected: %s, but got %v",
|
||||
t.Fatalf("Incorrect error.\nExpected:\n %s\nGot:\n%v",
|
||||
test.expectedErr, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user