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")
	}
}
