mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
add test case for error inside variables.
This commit is contained in:
parent
dc832c6e59
commit
3e777540fd
@ -502,6 +502,35 @@ func TestTypeCheck(t *testing.T) {
|
||||
toContain("found no matching overload for '_==_' applied to '(string, int)"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error in variables, not reported during type checking.",
|
||||
policy: &v1beta1.ValidatingAdmissionPolicy{Spec: v1beta1.ValidatingAdmissionPolicySpec{
|
||||
Variables: []v1beta1.Variable{
|
||||
{
|
||||
Name: "name",
|
||||
Expression: "object.foo == 'str'",
|
||||
},
|
||||
},
|
||||
Validations: []v1beta1.Validation{
|
||||
{
|
||||
Expression: "variables.name == object.foo", // foo is int64
|
||||
},
|
||||
},
|
||||
MatchConstraints: deploymentPolicy.Spec.MatchConstraints,
|
||||
},
|
||||
},
|
||||
schemaToReturn: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"foo": *spec.Int64Property(),
|
||||
},
|
||||
},
|
||||
},
|
||||
assertions: []assertionFunc{
|
||||
toHaveLengthOf(0),
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
typeChecker := buildTypeChecker(tc.schemaToReturn)
|
||||
|
Loading…
Reference in New Issue
Block a user