File tree Expand file tree Collapse file tree
Tests/ApolloTests/WebSocket Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -224,12 +224,13 @@ public class WebSocketTransport {
224224 }
225225
226226 public func initServer( ) {
227- self . acked = false
227+ processingQueue. async {
228+ self . acked = false
228229
229- if let str = OperationMessage ( payload: self . connectingPayload, type: . connectionInit) . rawMessage {
230- write ( str, force: true )
230+ if let str = OperationMessage ( payload: self . connectingPayload, type: . connectionInit) . rawMessage {
231+ self . write ( str, force: true )
232+ }
231233 }
232-
233234 }
234235
235236 public func closeConnection( ) {
Original file line number Diff line number Diff line change @@ -48,6 +48,23 @@ class WebSocketTransportTests: XCTestCase {
4848
4949 waitForExpectations ( timeout: 3 , handler: nil )
5050 }
51+
52+ func testCloseConnectionAndInit( ) {
53+ WebSocketTransport . provider = MockWebSocket . self
54+
55+ self . webSocketTransport = WebSocketTransport ( request: URLRequest ( url: TestURL . mockServer. url) ,
56+ connectingPayload: [ " Authorization " : " OldToken " ] )
57+ self . webSocketTransport. closeConnection ( )
58+ self . webSocketTransport. updateConnectingPayload ( [ " Authorization " : " UpdatedToken " ] )
59+ self . webSocketTransport. initServer ( )
60+
61+ let exp = expectation ( description: " Wait " )
62+ let result = XCTWaiter . wait ( for: [ exp] , timeout: 1.0 )
63+ if result == XCTWaiter . Result. timedOut {
64+ } else {
65+ XCTFail ( " Delay interrupted " )
66+ }
67+ }
5168}
5269
5370private final class MockWebSocketDelegate : WebSocketDelegate {
You can’t perform that action at this time.
0 commit comments