Skip to content

Commit 349aacf

Browse files
authored
chore: testing queue is full. (#1)
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 0d72ae2 commit 349aacf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Queue
22

33
[![Run Tests](https://github.com/appleboy/queue/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/appleboy/queue/actions/workflows/go.yml)
4+
[![codecov](https://codecov.io/gh/appleboy/queue/branch/master/graph/badge.svg?token=V8A1WA0P5E)](https://codecov.io/gh/appleboy/queue)
45

56
Queue is a Golang library for spawning and managing a Goroutine pool, Alloowing you to create multiple worker according to limit CPU number of machine.

queue_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,23 @@ func TestWorkerPanic(t *testing.T) {
121121
q.Wait()
122122
assert.Equal(t, 0, q.Workers())
123123
}
124+
125+
func TestCapacityReached(t *testing.T) {
126+
w := &queueWorker{
127+
messages: make(chan QueuedMessage, 1),
128+
}
129+
q, err := NewQueue(
130+
WithWorker(w),
131+
WithWorkerCount(5),
132+
)
133+
assert.NoError(t, err)
134+
assert.NotNil(t, q)
135+
136+
assert.NoError(t, q.Queue(mockMessage{
137+
message: "foobar",
138+
}))
139+
// max capacity reached
140+
assert.Error(t, q.Queue(mockMessage{
141+
message: "foobar",
142+
}))
143+
}

0 commit comments

Comments
 (0)