Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2024-10-24 21:57:51 +02:00
parent 1518c4ec16
commit 0d825361e6

View File

@ -18,6 +18,9 @@ package cel
import (
"testing"
"github.com/google/cel-go/common/types"
"github.com/stretchr/testify/assert"
)
func TestTypes_ListType(t *testing.T) {
@ -77,3 +80,16 @@ func testValue(t *testing.T, id int64, val interface{}) *DynValue {
}
return dv
}
func TestDeclTypeProvider_FindStructType(t *testing.T) {
obj := NewObjectType("foo", map[string]*DeclField{
"bar": NewDeclField("bar", StringType, true, nil, nil),
})
base := types.NewEmptyRegistry()
provider := NewDeclTypeProvider(obj)
provider, err := provider.WithTypeProvider(base)
assert.NoError(t, err)
wrappedType, found := provider.FindStructType("foo")
assert.True(t, found)
assert.Equal(t, types.TypeKind, wrappedType.Kind())
}