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

Function TestPolicyAndRuleSemanticMethods

policy/parser_test.go:430–461  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

428}
429
430func TestPolicyAndRuleSemanticMethods(t *testing.T) {
431 p := NewPolicy(nil, nil)
432 if p.Semantic() != firstMatch {
433 t.Errorf("got %v, wanted firstMatch", p.Semantic())
434 }
435 p.SetSemantic(aggregate)
436 if p.Semantic() != aggregate {
437 t.Errorf("got %v, wanted aggregate", p.Semantic())
438 }
439 // Attempt to set conflicting semantic
440 p.SetSemantic(firstMatch)
441 if p.Semantic() != aggregate {
442 t.Errorf("got %v, wanted aggregate after conflicting SetSemantic", p.Semantic())
443 }
444
445 r := NewRule(123)
446 if r.SourceID() != 123 {
447 t.Errorf("got %v, wanted 123", r.SourceID())
448 }
449 if r.Semantic() != firstMatch {
450 t.Errorf("got %v, wanted firstMatch", r.Semantic())
451 }
452 r.SetSemantic(aggregate)
453 if r.Semantic() != aggregate {
454 t.Errorf("got %v, wanted aggregate", r.Semantic())
455 }
456 // Attempt to set conflicting semantic
457 r.SetSemantic(firstMatch)
458 if r.Semantic() != aggregate {
459 t.Errorf("got %v, wanted aggregate after conflicting SetSemantic", r.Semantic())
460 }
461}

Callers

nothing calls this directly

Calls 7

SemanticMethod · 0.95
SetSemanticMethod · 0.95
SourceIDMethod · 0.95
SemanticMethod · 0.95
SetSemanticMethod · 0.95
NewPolicyFunction · 0.85
NewRuleFunction · 0.85

Tested by

no test coverage detected