MCPcopy
hub / github.com/expr-lang/expr / TestBuiltin_memory_limits

Function TestBuiltin_memory_limits

builtin/builtin_test.go:347–378  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

345}
346
347func TestBuiltin_memory_limits(t *testing.T) {
348 tests := []struct {
349 input string
350 }{
351 {`repeat("\xc4<\xc4\xc4\xc4",10009999990)`},
352 }
353
354 for _, test := range tests {
355 t.Run(test.input, func(t *testing.T) {
356 timeout := make(chan bool, 1)
357 go func() {
358 time.Sleep(time.Second)
359 timeout <- true
360 }()
361
362 done := make(chan bool, 1)
363 go func() {
364 _, err := expr.Eval(test.input, nil)
365 assert.Error(t, err)
366 assert.Contains(t, err.Error(), "memory budget exceeded")
367 done <- true
368 }()
369
370 select {
371 case <-done:
372 // Success.
373 case <-timeout:
374 t.Fatal("timeout")
375 }
376 })
377 }
378}
379
380func TestBuiltin_allow_builtins_override(t *testing.T) {
381 t.Run("via env var", func(t *testing.T) {

Callers

nothing calls this directly

Calls 5

EvalFunction · 0.92
ErrorFunction · 0.92
ContainsFunction · 0.92
RunMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…