Merge pull request #119577 from jiahuif-forks/tests/validating-admission-policy/lazy-map-short-circuiting

CEL lazy map: add test for boolean short-circuiting
This commit is contained in:
Kubernetes Prow Robot
2023-08-15 19:43:04 -07:00
committed by GitHub

View File

@@ -93,6 +93,17 @@ func TestLazyMapType(t *testing.T) {
if evalCounter != 1 {
t.Errorf("expected eval %d times but got %d", 1, evalCounter)
}
// unused due to boolean short-circuiting
// if `variables.unused` is evaluated, the whole test will have a fatal error and exit.
exp = "variables.dict.a == 'wrong' && variables.unused == 'unused'"
v, err = compileAndRun(env, activation, exp)
if err != nil {
t.Fatalf("%q: %v", exp, err)
}
if v.Value().(bool) != false {
t.Errorf("%q: wrong result: %v", exp, v.Value())
}
}
type testActivation struct {