(t *testing.T)
| 93 | } |
| 94 | |
| 95 | func TestEncodersVersion(t *testing.T) { |
| 96 | env, err := cel.NewEnv(Encoders(EncodersVersion(0))) |
| 97 | if err != nil { |
| 98 | t.Fatalf("EncodersVersion(0) failed: %v", err) |
| 99 | } |
| 100 | if _, iss := env.Compile("base64.encode(b'hello')"); iss.Err() != nil { |
| 101 | t.Fatalf("base64.encode() got %v, wanted no error", iss.Err()) |
| 102 | } |
| 103 | if _, iss := env.Compile("json.encode('hello')"); iss.Err() == nil { |
| 104 | t.Fatal("json.encode() got no error, wanted version-gated function to be unavailable") |
| 105 | } |
| 106 | |
| 107 | env, err = cel.NewEnv(Encoders(EncodersVersion(1))) |
| 108 | if err != nil { |
| 109 | t.Fatalf("EncodersVersion(1) failed: %v", err) |
| 110 | } |
| 111 | if _, iss := env.Compile("json.encode('hello')"); iss.Err() != nil { |
| 112 | t.Fatalf("json.encode() got %v, wanted no error", iss.Err()) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | func testEncodersCostsEnv(t *testing.T, version int, opts ...cel.EnvOption) *cel.Env { |
| 117 | t.Helper() |
nothing calls this directly
no test coverage detected