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

Function TestQualifyIfPresent

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

Source from the content-addressed store, hash-verified

1409}
1410
1411func TestQualifyIfPresent(t *testing.T) {
1412 reg := newTestRegistry(t)
1413 cont := containers.DefaultContainer
1414 fac := NewAttributeFactory(cont, reg, reg)
1415 activation, _ := NewActivation(map[string]any{
1416 "a": "b",
1417 "c": int64(1),
1418 })
1419
1420 tests := []struct {
1421 name string
1422 qual Qualifier
1423 obj any
1424 out any
1425 }{
1426 {
1427 name: "absolute_attribute",
1428 qual: fac.AbsoluteAttribute(1, "a"),
1429 obj: map[string]any{"b": 100},
1430 out: 100,
1431 },
1432 {
1433 name: "maybe_attribute",
1434 qual: fac.MaybeAttribute(1, "a"),
1435 obj: map[string]any{"b": 100},
1436 out: 100,
1437 },
1438 {
1439 name: "relative_attribute",
1440 qual: fac.RelativeAttribute(2, NewConstValue(1, types.String("b"))),
1441 obj: map[string]any{"b": 200},
1442 out: 200,
1443 },
1444 {
1445 name: "string_qualifier",
1446 qual: makeOptQualifier(t, fac, nil, 1, "b"),
1447 obj: map[string]any{"b": 300},
1448 out: 300,
1449 },
1450 {
1451 name: "int_qualifier",
1452 qual: makeOptQualifier(t, fac, nil, 1, int64(1)),
1453 obj: map[int64]any{int64(1): "value"},
1454 out: "value",
1455 },
1456 {
1457 name: "uint_qualifier",
1458 qual: makeOptQualifier(t, fac, nil, 1, uint64(1)),
1459 obj: map[uint64]any{uint64(1): "uvalue"},
1460 out: "uvalue",
1461 },
1462 {
1463 name: "bool_qualifier",
1464 qual: makeOptQualifier(t, fac, nil, 1, true),
1465 obj: map[bool]any{true: "bvalue"},
1466 out: "bvalue",
1467 },
1468 }

Callers

nothing calls this directly

Calls 10

AbsoluteAttributeMethod · 0.95
MaybeAttributeMethod · 0.95
RelativeAttributeMethod · 0.95
StringTypeAlias · 0.92
NewAttributeFactoryFunction · 0.85
NewConstValueFunction · 0.85
makeOptQualifierFunction · 0.85
newTestRegistryFunction · 0.70
NewActivationFunction · 0.70
QualifyIfPresentMethod · 0.65

Tested by

no test coverage detected