This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user