MCPcopy Create free account
hub / github.com/dc0d/workerpool / TestZeroWorkers

Function TestZeroWorkers

workerpool_usage_test.go:36–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestZeroWorkers(t *testing.T) {
37 pool := workerpool.New(0, 0)
38
39 var backSlot int64 = 10
40 var job = func() {
41 atomic.StoreInt64(&backSlot, 110)
42 }
43 pool.Queue(job, 0)
44
45 assert.Equal(t, int64(10), atomic.LoadInt64(&backSlot))
46
47 pool.Expand(1, 0, nil)
48
49 done := make(chan bool)
50 job = func() {
51 defer close(done)
52 atomic.StoreInt64(&backSlot, 73)
53 }
54 assert.True(t, pool.Queue(job, time.Millisecond*50))
55 <-done
56
57 assert.Equal(t, int64(73), atomic.LoadInt64(&backSlot))
58
59 assert.NoError(t, waitFunc(pool.Stop, _timeout))
60}
61
62func TestAbsoluteTimeout(t *testing.T) {
63 initialWorkers := 1

Callers

nothing calls this directly

Calls 3

waitFuncFunction · 0.85
QueueMethod · 0.80
ExpandMethod · 0.80

Tested by

no test coverage detected