Skip to content

Commit

Permalink
web: fix test goroutine in TestTLS()
Browse files Browse the repository at this point in the history
  • Loading branch information
alrs committed Dec 9, 2019
1 parent 55ab44c commit f25ad35
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions web/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ func TestTLS(t *testing.T) {

service.HandleFunc("/", fn)

errCh := make(chan error, 1)
go func() {
if err := service.Run(); err != nil {
t.Fatal(err)
}
errCh <- service.Run()
close(errCh)
}()

var s []*registry.Service
Expand Down Expand Up @@ -257,4 +257,13 @@ func TestTLS(t *testing.T) {
if string(b) != str {
t.Errorf("Expected %s got %s", str, string(b))
}

select {
case err := <-errCh:
if err != nil {
t.Fatalf("Run():%v", err)
}
case <-time.After(time.Duration(time.Second)):
t.Logf("service.Run() survived a client request without an error")
}
}

0 comments on commit f25ad35

Please sign in to comment.