MCPcopy
hub / github.com/grafana/dskit / TestAsyncQueue_QueueFullError

Function TestAsyncQueue_QueueFullError

cache/async_queue_test.go:29–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestAsyncQueue_QueueFullError(t *testing.T) {
30 const queueLength = 10
31
32 q := newAsyncQueue(queueLength, 1)
33 defer q.stop()
34
35 doneCh := make(chan struct{})
36 defer func() {
37 close(doneCh)
38 }()
39
40 // Keep worker busy.
41 _ = q.submit(func() {
42 <-doneCh
43 })
44 time.Sleep(100 * time.Millisecond)
45
46 // Fill the queue.
47 for i := 0; i < queueLength; i++ {
48 require.NoError(t, q.submit(func() {}))
49 }
50
51 require.ErrorIs(t, q.submit(func() {}), errAsyncQueueFull)
52}

Callers

nothing calls this directly

Calls 4

newAsyncQueueFunction · 0.85
submitMethod · 0.80
SleepMethod · 0.65
stopMethod · 0.45

Tested by

no test coverage detected