Public source validation / validate (push) Failing after 3m8s
26 lines
452 B
Go
26 lines
452 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestWaitForStopReturnsOnSignal(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
signals := make(chan os.Signal, 1)
|
|
done := make(chan struct{})
|
|
go func() {
|
|
WaitForStop(ctx, signals)
|
|
close(done)
|
|
}()
|
|
signals <- os.Interrupt
|
|
select {
|
|
case <-done:
|
|
case <-time.After(time.Second):
|
|
t.Fatal("shutdown did not return after signal")
|
|
}
|
|
}
|