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

Function TestOverrideValidatorPreservesOrder

cel/validator_test.go:573–599  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

571}
572
573func TestOverrideValidatorPreservesOrder(t *testing.T) {
574 v1 := ValidateDurationLiterals()
575 v2 := ValidateComprehensionNestingLimit(2)
576 v3 := ValidateTimestampLiterals()
577
578 env1, err := NewEnv(ASTValidators(v1, v2, v3))
579 if err != nil {
580 t.Fatalf("NewEnv() failed: %v", err)
581 }
582
583 v2New := ValidateComprehensionNestingLimit(5)
584 env2, err := env1.Extend(ASTValidators(v2New))
585 if err != nil {
586 t.Fatalf("Extend() failed: %v", err)
587 }
588
589 validators := env2.Validators()
590 if len(validators) != 3 {
591 t.Fatalf("got %d validators, wanted 3", len(validators))
592 }
593 if validators[0].Name() != v1.Name() || validators[1].Name() != v2.Name() || validators[2].Name() != v3.Name() {
594 t.Fatalf("validator order or names unexpected: %v, %v, %v", validators[0].Name(), validators[1].Name(), validators[2].Name())
595 }
596 if val, ok := validators[1].(nestingLimitValidator); !ok || val.limit != 5 {
597 t.Fatalf("expected overridden nesting limit validator with limit 5, got %v", validators[1])
598 }
599}
600
601func TestValidateLiteralsInAsyncEnv(t *testing.T) {
602 env, err := NewEnv(

Callers

nothing calls this directly

Calls 8

ExtendMethod · 0.95
ValidateDurationLiteralsFunction · 0.85
ASTValidatorsFunction · 0.85
ValidatorsMethod · 0.80
NewEnvFunction · 0.70
NameMethod · 0.65

Tested by

no test coverage detected