Files
pipelines/internal/server/worker_shutdown_test.go
T

33 lines
656 B
Go

package server
import (
"context"
"path/filepath"
"testing"
"time"
"git.a-wan.net/alan/pipelines/internal/pipeline"
)
func TestNotificationWorkerStopsWhenEmbeddedStoreCloses(t *testing.T) {
store, err := pipeline.Open(filepath.Join(t.TempDir(), "workers.db"))
if err != nil {
t.Fatal(err)
}
r, err := newRunner(context.Background(), store)
if err != nil {
store.Close()
t.Fatal(err)
}
if err := store.Close(); err != nil {
t.Fatal(err)
}
done := make(chan struct{})
go func() { r.schedulerWG.Wait(); close(done) }()
select {
case <-done:
case <-time.After(time.Second):
t.Fatal("notification worker outlived its store")
}
}