MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestNativeFindStructFieldNames

Function TestNativeFindStructFieldNames

ext/native_test.go:324–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

322}
323
324func TestNativeFindStructFieldNames(t *testing.T) {
325 env := testNativeEnv(t, ParseStructTags(true))
326 provider := env.CELTypeProvider()
327 tests := []struct {
328 typeName string
329 fields []string
330 }{
331 {
332 typeName: "ext.TestNestedType",
333 fields: []string{"NestedListVal", "NestedMapVal", "custom_name"},
334 },
335 {
336 typeName: "google.expr.proto3.test.TestAllTypes.NestedMessage",
337 fields: []string{"bb"},
338 },
339 {
340 typeName: "invalid.TypeName",
341 fields: []string{},
342 },
343 }
344
345 for _, tst := range tests {
346 tc := tst
347 t.Run(fmt.Sprintf("%s", tc.typeName), func(t *testing.T) {
348 fields, _ := provider.FindStructFieldNames(tc.typeName)
349 sort.Strings(fields)
350 sort.Strings(tc.fields)
351 if !reflect.DeepEqual(fields, tc.fields) {
352 t.Errorf("got %v, wanted %v", fields, tc.fields)
353 }
354 })
355 }
356}
357
358func TestNativeTypesStaticErrors(t *testing.T) {
359 var nativeTests = []struct {

Callers

nothing calls this directly

Calls 4

testNativeEnvFunction · 0.85
ParseStructTagsFunction · 0.85
CELTypeProviderMethod · 0.80
FindStructFieldNamesMethod · 0.65

Tested by

no test coverage detected