hyapp-server/pkg/servicekit/app/background_test.go
2026-06-23 11:53:00 +08:00

23 lines
386 B
Go

package app
import (
"context"
"testing"
"time"
)
func TestBackgroundGroupStopAndWait(t *testing.T) {
group := NewBackground(context.Background())
done := make(chan struct{})
group.Go(func(ctx context.Context) {
<-ctx.Done()
close(done)
})
group.StopAndWait()
select {
case <-done:
case <-time.After(time.Second):
t.Fatalf("worker did not observe cancellation")
}
}