mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-29 21:35:50 +00:00
extra case for affirmative has(map) test.
This commit is contained in:
parent
d0c323fb8f
commit
d699163802
@ -87,6 +87,11 @@ func TestCELOptional(t *testing.T) {
|
|||||||
// types.OptionalNone.Value() is nil
|
// types.OptionalNone.Value() is nil
|
||||||
expectedValue: nil,
|
expectedValue: nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "map existing field, return actual value",
|
||||||
|
expression: `{"foo": 1}[?"foo"]`,
|
||||||
|
expectedValue: int64(1), // CEL int converts into int64
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// Map has a different behavior than Object
|
// Map has a different behavior than Object
|
||||||
//
|
//
|
||||||
@ -98,11 +103,17 @@ func TestCELOptional(t *testing.T) {
|
|||||||
// 1. If e evaluates to a map, then has(e.f) indicates whether the string f is
|
// 1. If e evaluates to a map, then has(e.f) indicates whether the string f is
|
||||||
// a key in the map (note that f must syntactically be an identifier).
|
// a key in the map (note that f must syntactically be an identifier).
|
||||||
//
|
//
|
||||||
name: "has on a map, de-sugared, return false",
|
name: "has on a map, de-sugared, non-existing field, returns false",
|
||||||
// has marco supports only the dot access syntax.
|
// has marco supports only the dot access syntax.
|
||||||
expression: `has({"foo": 1}.bar)`,
|
expression: `has({"foo": 1}.bar)`,
|
||||||
expectedValue: false,
|
expectedValue: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "has on a map, de-sugared, existing field, returns true",
|
||||||
|
// has marco supports only the dot access syntax.
|
||||||
|
expression: `has({"foo": 1}.foo)`,
|
||||||
|
expectedValue: true,
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
_, option := NewTypeProviderAndEnvOption(&mockTypeResolverForOptional{
|
_, option := NewTypeProviderAndEnvOption(&mockTypeResolverForOptional{
|
||||||
|
Loading…
Reference in New Issue
Block a user