fix(task): fix task tests

This commit is contained in:
yusing 2025-05-29 20:42:36 +08:00
parent 72923b8cfa
commit 93a81fd558

View file

@ -49,7 +49,7 @@ func TestTaskStuck(t *testing.T) {
}) })
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
task.Finish(nil) task.FinishAndWait(nil)
close(done) close(done)
}() }()
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 100)
@ -81,7 +81,7 @@ func TestTaskOnCancelOnFinished(t *testing.T) {
}) })
expect.False(t, shouldTrueOnFinish) expect.False(t, shouldTrueOnFinish)
task.Finish(nil) task.FinishAndWait(nil)
expect.True(t, shouldTrueOnCancel) expect.True(t, shouldTrueOnCancel)
expect.True(t, shouldTrueOnFinish) expect.True(t, shouldTrueOnFinish)
} }
@ -97,7 +97,7 @@ func TestCommonFlowWithGracefulShutdown(t *testing.T) {
}) })
go func() { go func() {
defer task.Finish(nil) defer task.FinishAndWait(nil)
for { for {
select { select {
case <-task.Context().Done(): case <-task.Context().Done():