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

Function TestAttributesOneofAttr

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

Source from the content-addressed store, hash-verified

300}
301
302func TestAttributesOneofAttr(t *testing.T) {
303 reg := newTestRegistry(t)
304 cont, err := containers.NewContainer(containers.Name("acme.ns"))
305 if err != nil {
306 t.Fatal(err)
307 }
308 attrs := NewAttributeFactory(cont, reg, reg)
309 data := map[string]any{
310 "a": map[string]any{
311 "b": []int32{2, 42},
312 },
313 "acme.a.b": 1,
314 "acme.ns.a.b": "found",
315 }
316 vars, _ := NewActivation(data)
317
318 // a.b -> should resolve to acme.ns.a.b per namespace resolution rules.
319 attr := attrs.MaybeAttribute(1, "a")
320 qualB := makeQualifier(t, attrs, nil, 2, "b")
321 attr.AddQualifier(qualB)
322 out, err := attr.Resolve(vars)
323 if err != nil {
324 t.Fatal(err)
325 }
326 if out != "found" {
327 t.Errorf("Got %v, wanted 'found'", out)
328 }
329}
330
331func TestAttributesConditionalAttrTrueBranch(t *testing.T) {
332 reg := newTestRegistry(t)

Callers

nothing calls this directly

Calls 9

MaybeAttributeMethod · 0.95
NewContainerFunction · 0.92
NameFunction · 0.92
NewAttributeFactoryFunction · 0.85
makeQualifierFunction · 0.85
newTestRegistryFunction · 0.70
NewActivationFunction · 0.70
AddQualifierMethod · 0.65
ResolveMethod · 0.65

Tested by

no test coverage detected