(t *testing.T)
| 213 | } |
| 214 | |
| 215 | func 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 | |
| 238 | func TestTimeoutBindingEnforcesAgainstContextIgnoringOp(t *testing.T) { |
| 239 | // The wrapped op sleeps well past the timeout without consulting its context. TimeoutBinding |
nothing calls this directly
no test coverage detected