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

Function TestAttribute_StringRepresentation

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

Source from the content-addressed store, hash-verified

1673}
1674
1675func TestAttribute_StringRepresentation(t *testing.T) {
1676 reg := newTestRegistry(t)
1677 cont := containers.DefaultContainer
1678 fac := NewAttributeFactory(cont, reg, reg)
1679
1680 ident := fac.AbsoluteAttribute(1, "a")
1681 abs := fac.AbsoluteAttribute(2, "a.b", "b")
1682 maybe := fac.MaybeAttribute(3, "c")
1683 rel := fac.RelativeAttribute(4, NewConstValue(1, types.String("d")))
1684 cond := fac.ConditionalAttribute(5, NewConstValue(1, types.True), abs, maybe)
1685 trail := types.NewAttributeTrail("x")
1686
1687 tests := []struct {
1688 name string
1689 stringer fmt.Stringer
1690 }{
1691 {name: "identAttribute", stringer: ident.(fmt.Stringer)},
1692 {name: "absoluteAttribute", stringer: abs.(fmt.Stringer)},
1693 {name: "maybeAttribute", stringer: maybe.(fmt.Stringer)},
1694 {name: "relativeAttribute", stringer: rel.(fmt.Stringer)},
1695 {name: "conditionalAttribute", stringer: cond.(fmt.Stringer)},
1696 {name: "AttributeTrail", stringer: trail},
1697 }
1698 for _, tc := range tests {
1699 t.Run(tc.name, func(t *testing.T) {
1700 if str := tc.stringer.String(); str == "" {
1701 t.Errorf("%s.String() returned empty string", tc.name)
1702 }
1703 })
1704 }
1705}
1706
1707func TestIdentAttribute(t *testing.T) {
1708 reg := newTestRegistry(t)

Callers

nothing calls this directly

Calls 10

AbsoluteAttributeMethod · 0.95
MaybeAttributeMethod · 0.95
RelativeAttributeMethod · 0.95
ConditionalAttributeMethod · 0.95
StringTypeAlias · 0.92
NewAttributeTrailFunction · 0.92
NewAttributeFactoryFunction · 0.85
NewConstValueFunction · 0.85
newTestRegistryFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected