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

Function TestResolverCustomQualifier

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

Source from the content-addressed store, hash-verified

852}
853
854func TestResolverCustomQualifier(t *testing.T) {
855 reg := newTestRegistry(t)
856 attrs := &custAttrFactory{
857 AttributeFactory: NewAttributeFactory(containers.DefaultContainer, reg, reg),
858 }
859 msg := &proto3pb.TestAllTypes_NestedMessage{
860 Bb: 123,
861 }
862 vars, _ := NewActivation(map[string]any{
863 "msg": msg,
864 })
865 attr := attrs.AbsoluteAttribute(1, "msg")
866 fieldType := types.NewObjectType("google.expr.proto3.test.TestAllTypes.NestedMessage")
867 qualBB := makeQualifier(t, attrs, fieldType, 2, "bb")
868 attr.AddQualifier(qualBB)
869 out, err := attr.Resolve(vars)
870 if err != nil {
871 t.Error(err)
872 }
873 if out != int32(123) {
874 t.Errorf("Got %v, wanted 123", out)
875 }
876}
877
878func TestAttributesMissingMsg(t *testing.T) {
879 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