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

Function TestCustomEnv

cel/cel_test.go:312–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

310}
311
312func TestCustomEnv(t *testing.T) {
313 env, err := NewCustomEnv(Variable("a.b.c", BoolType))
314 if err != nil {
315 t.Fatalf("NewCustomEnv(a.b.c:bool) failed: %v", err)
316 }
317 t.Run("err", func(t *testing.T) {
318 _, iss := compileOrError(t, env, "a.b.c == true")
319 if iss == nil {
320 t.Error("got successful compile, expected error for missing operator '_==_'")
321 }
322 })
323
324 t.Run("ok", func(t *testing.T) {
325 out, err := interpret(t, env, "a.b.c", map[string]any{"a.b.c": true})
326 if err != nil {
327 t.Fatal(err)
328 }
329 if out != types.True {
330 t.Errorf("got '%v', wanted 'true'", out.Value())
331 }
332 })
333}
334
335func TestCrossTypeNumericComparisons(t *testing.T) {
336 tests := []struct {

Callers

nothing calls this directly

Calls 6

NewCustomEnvFunction · 0.85
compileOrErrorFunction · 0.85
interpretFunction · 0.85
VariableFunction · 0.70
ValueMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected