Skip to content

Commit

Permalink
test: improve reliability of mockwebserver websocket test (ws wait)
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Aug 29, 2024
1 parent 0543463 commit b0407d0
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class DefaultMockServerWebSocketTest extends Specification {
given: "A WebSocket expectation"
server.expect()
.withPath("/websocket")
.andUpgradeToWebSocket().open().done().always()
.andUpgradeToWebSocket().open().waitFor(10L).andEmit("done").done().always()
and:
def future = new CompletableFuture()
and: "A WebSocket request"
Expand All @@ -197,8 +197,9 @@ class DefaultMockServerWebSocketTest extends Specification {
future.complete(ws.result().headers().get("sec-websocket-protocol"))
}
}
if (wsReq.result() != null && wsReq.result().headers() != null) {
future.complete(wsReq.result().headers().get("sec-websocket-protocol"))
def currentResult = wsReq.result()
if (currentResult != null && currentResult.headers() != null) {
future.complete(currentResult.headers().get("sec-websocket-protocol"))
}
and: "An instance of AsyncConditions"
def async = new AsyncConditions(1)
Expand Down

0 comments on commit b0407d0

Please sign in to comment.