Use sync.WaitGroup for shutdown

This commit is contained in:
Ken Hibino
2020-02-15 23:14:30 -08:00
parent 2bcaea52ce
commit 3d9a222bb3
11 changed files with 51 additions and 18 deletions

View File

@@ -5,6 +5,7 @@
package asynq
import (
"sync"
"testing"
"time"
@@ -15,6 +16,7 @@ import (
"github.com/hibiken/asynq/internal/rdb"
)
// FIXME: Make this test better.
func TestHeartbeater(t *testing.T) {
r := setup(t)
rdbClient := rdb.NewRDB(r)
@@ -46,7 +48,8 @@ func TestHeartbeater(t *testing.T) {
Started: time.Now(),
State: "running",
}
hb.start()
var wg sync.WaitGroup
hb.start(&wg)
// allow for heartbeater to write to redis
time.Sleep(tc.interval * 2)