Skip to content

Commit

Permalink
Use time.AfterFunc instead of spawning goroutine (#1266)
Browse files Browse the repository at this point in the history
This PR simplifies the test `TestNavigateContextTimeout`.

`time.AfterFunc` calls `cancel` in its own goroutine after the timeout.
  • Loading branch information
alexandear committed Feb 24, 2023
1 parent 1738691 commit 448735f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions nav_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,7 @@ func TestNavigateContextTimeout(t *testing.T) {
// Navigate shouldn't block waiting for the load to finish, which may
// not come as the target is cancelled.
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
go func() {
time.Sleep(time.Millisecond)
cancel()
}()
time.AfterFunc(time.Millisecond, cancel)
}))
defer s.Close()

Expand Down

0 comments on commit 448735f

Please sign in to comment.