Skip to content

Commit 0d82536

Browse files
committed
add test
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
1 parent 1518c4e commit 0d82536

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

staging/src/k8s.io/apiserver/pkg/cel/types_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ package cel
1818

1919
import (
2020
"testing"
21+
22+
"github.com/google/cel-go/common/types"
23+
"github.com/stretchr/testify/assert"
2124
)
2225

2326
func TestTypes_ListType(t *testing.T) {
@@ -77,3 +80,16 @@ func testValue(t *testing.T, id int64, val interface{}) *DynValue {
7780
}
7881
return dv
7982
}
83+
84+
func TestDeclTypeProvider_FindStructType(t *testing.T) {
85+
obj := NewObjectType("foo", map[string]*DeclField{
86+
"bar": NewDeclField("bar", StringType, true, nil, nil),
87+
})
88+
base := types.NewEmptyRegistry()
89+
provider := NewDeclTypeProvider(obj)
90+
provider, err := provider.WithTypeProvider(base)
91+
assert.NoError(t, err)
92+
wrappedType, found := provider.FindStructType("foo")
93+
assert.True(t, found)
94+
assert.Equal(t, types.TypeKind, wrappedType.Kind())
95+
}

0 commit comments

Comments
 (0)