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

Function TestEnvCheckExtendRace

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

Source from the content-addressed store, hash-verified

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