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

Function TestEnvCheckExtendRace

cel/env_test.go:197–220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

195}
196
197func TestEnvCheckExtendRace(t *testing.T) {
198 t.Parallel()
199 for i := 0; i < 500; i++ {
200 wg := &sync.WaitGroup{}
201 wg.Add(2)
202 env, err := NewCustomEnv(StdLib())
203 if err != nil {
204 t.Fatalf("NewCustomEnv() failed: %v", err)
205 }
206 t.Run(fmt.Sprintf("Compile[%d]", i), func(t *testing.T) {
207 go func() {
208 defer wg.Done()
209 _, _ = env.Compile(`1 + 1 * 20 < 400`)
210 }()
211 })
212 t.Run(fmt.Sprintf("Extend[%d]", i), func(t *testing.T) {
213 go func() {
214 defer wg.Done()
215 _, _ = env.Extend(Variable("bar", BoolType))
216 }()
217 })
218 wg.Wait()
219 }
220}
221
222func TestEnvConcurrentExtend(t *testing.T) {
223 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewCustomEnvFunction · 0.85
StdLibFunction · 0.85
VariableFunction · 0.70
AddMethod · 0.65
CompileMethod · 0.65
ExtendMethod · 0.45

Tested by

no test coverage detected