Skip to content

Commit

Permalink
Explain approach of fallback host test
Browse files Browse the repository at this point in the history
I’m going to need to change this test in an upcoming commit and want the
original intent to be clear before I do.
  • Loading branch information
lawrence-forooghian committed Nov 6, 2023
1 parent c16c7e9 commit 373211c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Test/Tests/RealtimeClientConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3708,12 +3708,16 @@ class RealtimeClientConnectionTests: XCTestCase {
client.connect()
defer { client.dispose(); client.close() }

// We expect the first connection attempt to fail due to the .fakeNetworkResponse configured above. This error does not meet the criteria for trying a fallback host, and so should not provoke the use of a fallback host. Hence the connection should give up and transition to the FAILED state (which causes the publish to fail). We should see that there was only one connection attempt, to the primary host.

waitUntil(timeout: testTimeout) { done in
channel.publish(nil, data: "message") { _ in
channel.publish(nil, data: "message") { error in
XCTAssertNotNil(error)
done()
}
}

XCTAssertEqual(client.connection.state, .failed)
XCTAssertEqual(urlConnections.count, 1)
XCTAssertTrue(NSRegularExpression.match(urlConnections[0].absoluteString, pattern: "//realtime.ably.io"))
}
Expand Down

0 comments on commit 373211c

Please sign in to comment.