Skip to content

Commit

Permalink
Use longer async timeout for slower environments like CI
Browse files Browse the repository at this point in the history
  • Loading branch information
calvincestari committed Feb 24, 2022
1 parent 4178c66 commit d63d078
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
18 changes: 10 additions & 8 deletions Tests/ApolloTests/WebSocket/GraphqlTransportWsProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Apollo
import SubscriptionAPI

class GraphqlTransportWsProtocolTests: XCTestCase {
private let asyncTimeout: DispatchTimeInterval = .seconds(3)

private var store: ApolloStore!
private var mockWebSocket: MockWebSocket!
private var websocketTransport: WebSocketTransport! {
Expand Down Expand Up @@ -92,7 +94,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {
// given
buildWebSocket()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(payload: [:], type: .connectionInit))
Expand All @@ -110,7 +112,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {
// given
websocketTransport = WebSocketTransport(websocket: mockWebSocket, connectingPayload: nil)

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(type: .connectionInit))
Expand All @@ -131,7 +133,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {
connectingPayload: ["sample": "data"]
)

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(payload: ["sample": "data"], type: .connectionInit))
Expand All @@ -153,7 +155,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {

let operation = IncrementingSubscription()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(payload: operation.requestBody, id: "1", type: .subscribe))
Expand All @@ -175,7 +177,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {

let subject = client.subscribe(subscription: IncrementingSubscription()) { _ in }

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
let expected = OperationMessage(id: "1", type: .stop).rawMessage!
Expand All @@ -196,7 +198,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {
connectWebSocket()
ackConnection()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(type: .connectionTerminate))
Expand All @@ -218,7 +220,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {

let operation = IncrementingSubscription()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
// when
self.client.subscribe(subscription: operation) { result in
switch result {
Expand Down Expand Up @@ -248,7 +250,7 @@ class GraphqlTransportWsProtocolTests: XCTestCase {
connectWebSocket()
ackConnection()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(type: .pong))
Expand Down
16 changes: 9 additions & 7 deletions Tests/ApolloTests/WebSocket/GraphqlWsProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Apollo
import SubscriptionAPI

class GraphqlWsProtocolTests: XCTestCase {
private let asyncTimeout: DispatchTimeInterval = .seconds(3)

private var store: ApolloStore!
private var mockWebSocket: MockWebSocket!
private var websocketTransport: WebSocketTransport! {
Expand Down Expand Up @@ -92,7 +94,7 @@ class GraphqlWsProtocolTests: XCTestCase {
// given
buildWebSocket()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(payload: [:], type: .connectionInit))
Expand All @@ -110,7 +112,7 @@ class GraphqlWsProtocolTests: XCTestCase {
// given
websocketTransport = WebSocketTransport(websocket: mockWebSocket, connectingPayload: nil)

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(type: .connectionInit))
Expand All @@ -131,7 +133,7 @@ class GraphqlWsProtocolTests: XCTestCase {
connectingPayload: ["sample": "data"]
)

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(payload: ["sample": "data"], type: .connectionInit))
Expand All @@ -153,7 +155,7 @@ class GraphqlWsProtocolTests: XCTestCase {

let operation = IncrementingSubscription()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(payload: operation.requestBody, id: "1", type: .start))
Expand All @@ -175,7 +177,7 @@ class GraphqlWsProtocolTests: XCTestCase {

let subject = client.subscribe(subscription: IncrementingSubscription()) { _ in }

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
let expected = OperationMessage(id: "1", type: .stop).rawMessage!
Expand All @@ -196,7 +198,7 @@ class GraphqlWsProtocolTests: XCTestCase {
connectWebSocket()
ackConnection()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
self.mockWebSocketDelegate.didReceiveMessage = { message in
// then
expect(message).to(equalMessage(type: .connectionTerminate))
Expand All @@ -218,7 +220,7 @@ class GraphqlWsProtocolTests: XCTestCase {

let operation = IncrementingSubscription()

waitUntil { done in
waitUntil(timeout: asyncTimeout) { done in
// when
self.client.subscribe(subscription: operation) { result in
switch result {
Expand Down

0 comments on commit d63d078

Please sign in to comment.