(t *testing.T)
| 599 | } |
| 600 | |
| 601 | func TestValidateLiteralsInAsyncEnv(t *testing.T) { |
| 602 | env, err := NewEnv( |
| 603 | ExtendedValidations(), |
| 604 | Function("async_call", |
| 605 | Overload("async_call_string", []*Type{StringType}, StringType, |
| 606 | AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val { return args[0] }))), |
| 607 | ) |
| 608 | if err != nil { |
| 609 | t.Fatalf("NewEnv() failed: %v", err) |
| 610 | } |
| 611 | |
| 612 | // Duration and timestamp literal validations should succeed even in an async env. |
| 613 | _, iss := env.Compile(`duration('1h') < duration('2h') && timestamp('2023-01-01T00:00:00Z') < timestamp('2023-01-02T00:00:00Z')`) |
| 614 | if iss.Err() != nil { |
| 615 | t.Fatalf("env.Compile() valid literals failed: %v", iss.Err()) |
| 616 | } |
| 617 | |
| 618 | // Invalid literals should still report validation errors. |
| 619 | _, iss = env.Compile(`duration('invalid_duration')`) |
| 620 | if iss.Err() == nil { |
| 621 | t.Fatal("env.Compile() invalid duration expected error, got nil") |
| 622 | } |
| 623 | |
| 624 | _, iss = env.Compile(`timestamp('invalid_timestamp')`) |
| 625 | if iss.Err() == nil { |
| 626 | t.Fatal("env.Compile() invalid timestamp expected error, got nil") |
| 627 | } |
| 628 | } |
nothing calls this directly
no test coverage detected