Skip to content

Commit

Permalink
Added another test for DispatchEvery with multiple jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Borders committed Nov 2, 2018
1 parent a9e490e commit 39e20eb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ func TestDispatcher_DispatchEvery(t *testing.T) {
assert.Equal(t, 3, c)
}

func TestDispatcher_DispatchEvery_Multiple(t *testing.T) {
d := NewDispatcher(10, 10)
d.Start()

a := 0
b := 0

d.DispatchEvery(func() {
a++
}, time.Millisecond * 100)

d.DispatchEvery(func() {
b++
}, time.Millisecond * 200)

time.Sleep(time.Millisecond * 1050)
d.Stop()

assert.Equal(t, 10, a)
assert.Equal(t, 5, b)
}

func TestDispatcher_DispatchEvery_Stop(t *testing.T) {
c := 0

Expand Down

0 comments on commit 39e20eb

Please sign in to comment.