fix: stop active tasks before server shutdown

This commit is contained in:
kanzihuang
2024-05-01 23:34:03 +08:00
committed by wanli
parent 100bb89877
commit 86c772f6c1
4 changed files with 42 additions and 23 deletions

View File

@@ -2,7 +2,7 @@ package timeutil
import (
"context"
"github.com/stretchr/testify/require"
"github.com/hibiken/asynq/internal/errors"
"sync"
"testing"
"time"
@@ -37,7 +37,9 @@ func TestSleep(t *testing.T) {
go func() {
defer wg.Done()
err := Sleep(ctx, tc.sleep)
require.ErrorIs(t, tc.wantErr, err)
if !errors.Is(err, tc.wantErr) {
t.Errorf("timeutil.Sleep: got %v, want %v", err, tc.wantErr)
}
}()
time.Sleep(20 * time.Millisecond)
cancel()