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

Function TestDrainReady

cel/async/async_test.go:215–236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestDrainReady(t *testing.T) {
216 debounce := 10 * time.Millisecond
217 s := async.DrainReady(debounce)
218
219 // No pending calls -> re-evaluate immediately
220 action := s.NextAction([]async.Call{mockAsyncCall{}}, 0)
221 if !action.Reevaluate {
222 t.Error("DrainReady did not re-evaluate when no calls pending")
223 }
224
225 // No completions -> wait indefinitely
226 action = s.NextAction(nil, 1)
227 if action.Reevaluate || action.WaitDuration != 0 {
228 t.Errorf("DrainReady NextAction(nil, 1) = %v, want {false, 0}", action)
229 }
230
231 // Some completions, still pending -> wait for the debounce window
232 action = s.NextAction([]async.Call{mockAsyncCall{}}, 1)
233 if action.Reevaluate || action.WaitDuration != debounce {
234 t.Errorf("DrainReady NextAction(batch, 1) = %v, want {false, %v}", action, debounce)
235 }
236}
237
238func TestTimeoutBindingEnforcesAgainstContextIgnoringOp(t *testing.T) {
239 // The wrapped op sleeps well past the timeout without consulting its context. TimeoutBinding

Callers

nothing calls this directly

Calls 3

DrainReadyFunction · 0.92
NextActionMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected