Skip to content

Commit

Permalink
test(mockwebserver): fix concurrency issues
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Jan 2, 2024
1 parent de8e718 commit 2bd234b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ class DefaultMockServerTest extends Specification {
server.expect().get().withPath("/api/v1/users/watch")
.andUpgradeToWebSocket()
.open()
.immediately().andEmit("READY")
.waitFor(50L).andEmit("READY")
.expectHttpRequest("/api/v1/create").andEmit("CREATED").once()
.expectSentWebSocketMessage("CREATED").andEmit("WS-CREATED").once()
.done()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,13 @@ class DefaultMockServerWebSocketTest extends Specification {
def wsReq = wsClient.webSocket().connect(server.port, server.getHostName(), "/websocket")
and: "A WebSocket listener"
wsReq.onComplete { ws ->
ws.result().closeHandler { _ ->
ws.result().close()
if (ws.result().isClosed()) {
future.complete(ws.result().closeReason())
} else {
ws.result().closeHandler { _ ->
ws.result().close()
future.complete(ws.result().closeReason())
}
}
}
and: "An instance of AsyncConditions"
Expand Down

0 comments on commit 2bd234b

Please sign in to comment.