Skip to content

Commit

Permalink
fix: race condition when starting server in test
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Kocher <matthew.kocher@broadcom.com>
  • Loading branch information
acrmp authored and mkocher committed Apr 17, 2024
1 parent a5b858b commit f0bbf01
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/trafficcontroller/internal/proxy/firehose_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,17 @@ var _ = Describe("FirehoseHandler", func() {
server := httptest.NewServer(handler)
defer server.CloseClientConnections()

conn, _, err := websocket.DefaultDialer.Dial(
wsEndpoint(server, "/firehose/subscription-id"),
http.Header{"Authorization": []string{"token"}},
)
Expect(err).ToNot(HaveOccurred())

f := func() error {
_, _, err := conn.ReadMessage()
conn, _, err := websocket.DefaultDialer.Dial(
wsEndpoint(server, "/firehose/subscription-id"),
http.Header{"Authorization": []string{"token"}},
)
defer conn.Close()
if err != nil {
return err
}

_, _, err = conn.ReadMessage()
return err
}
Eventually(f).Should(MatchError(&websocket.CloseError{
Expand Down

0 comments on commit f0bbf01

Please sign in to comment.