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

Function TestResolverCustomQualifier

interpreter/attributes_test.go:1046–1068  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1044}
1045
1046func TestResolverCustomQualifier(t *testing.T) {
1047 reg := newTestRegistry(t)
1048 attrs := &custAttrFactory{
1049 AttributeFactory: NewAttributeFactory(containers.DefaultContainer, reg, reg),
1050 }
1051 msg := &proto3pb.TestAllTypes_NestedMessage{
1052 Bb: 123,
1053 }
1054 vars, _ := NewActivation(map[string]any{
1055 "msg": msg,
1056 })
1057 attr := attrs.AbsoluteAttribute(1, "msg")
1058 fieldType := types.NewObjectType("google.expr.proto3.test.TestAllTypes.NestedMessage")
1059 qualBB := makeQualifier(t, attrs, fieldType, 2, "bb")
1060 attr.AddQualifier(qualBB)
1061 out, err := attr.Resolve(vars)
1062 if err != nil {
1063 t.Error(err)
1064 }
1065 if out != int32(123) {
1066 t.Errorf("Got %v, wanted 123", out)
1067 }
1068}
1069
1070func TestAttributesMissingMsg(t *testing.T) {
1071 reg := newTestRegistry(t)

Callers

nothing calls this directly

Calls 9

NewObjectTypeFunction · 0.92
NewAttributeFactoryFunction · 0.85
makeQualifierFunction · 0.85
newTestRegistryFunction · 0.70
NewActivationFunction · 0.70
AbsoluteAttributeMethod · 0.65
AddQualifierMethod · 0.65
ResolveMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected