Skip to content

Commit

Permalink
catch interrupt in the test
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhang93 committed May 13, 2024
1 parent cfbbc24 commit f8297f6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/httplis/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ func TestStart(t *testing.T) {
Reloaded: false,
}

sigint := make(chan os.Signal, 1)
signal.Notify(sigint, syscall.SIGINT)

sigintRcvd := make(chan bool)

go func() {
<-sigint
sigintRcvd <- true
}()

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

Expand All @@ -168,7 +178,9 @@ func TestStart(t *testing.T) {
if resp.StatusCode != http.StatusOK {
t.Errorf("req failed with status %d", resp.StatusCode)
}

if rcvd := <-sigintRcvd; !rcvd {
t.Error("SIGINT was not received")
}
})

}
Expand Down

0 comments on commit f8297f6

Please sign in to comment.