From 491531508fd6b907e587434faf25b8fb2da8eced Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Thu, 4 May 2023 10:52:32 -0300 Subject: [PATCH] Move uniqueChannelName function to method on Test A bit more readable. --- Test/Test Utilities/Test.swift | 19 ++ Test/Test Utilities/TestUtilities.swift | 20 -- Test/Tests/AuthTests.swift | 46 +-- Test/Tests/DeltaCodecTests.swift | 6 +- Test/Tests/ObjectLifetimesTests.swift | 4 +- Test/Tests/PushAdminTests.swift | 8 +- Test/Tests/PushChannelTests.swift | 26 +- Test/Tests/ReadmeExamplesTests.swift | 20 +- Test/Tests/RealtimeClientChannelTests.swift | 286 +++++++++--------- Test/Tests/RealtimeClientChannelsTests.swift | 14 +- .../Tests/RealtimeClientConnectionTests.swift | 90 +++--- Test/Tests/RealtimeClientPresenceTests.swift | 220 +++++++------- Test/Tests/RealtimeClientTests.swift | 32 +- Test/Tests/RestClientChannelTests.swift | 92 +++--- Test/Tests/RestClientPresenceTests.swift | 22 +- Test/Tests/RestClientTests.swift | 144 ++++----- Test/Tests/UtilitiesTests.swift | 10 +- 17 files changed, 529 insertions(+), 530 deletions(-) diff --git a/Test/Test Utilities/Test.swift b/Test/Test Utilities/Test.swift index 42a3cbd7e..1832e53ff 100644 --- a/Test/Test Utilities/Test.swift +++ b/Test/Test Utilities/Test.swift @@ -9,4 +9,23 @@ struct Test { self.function = function NSLog("Created test \(id) for function \(function)") } + + func uniqueChannelName(prefix: String = "", + timestamp: TimeInterval = Date.timeIntervalSinceReferenceDate) -> String { + let platform: String + #if targetEnvironment(macCatalyst) + platform = "macCatalyst" + #elseif os(OSX) + platform = "OSX" + #elseif os(iOS) + platform = "iOS" + #elseif os(tvOS) + platform = "tvOS" + #elseif os(watchOS) + platform = "watchOS" + #else + platform = "Unknown" + #endif + return "\(prefix)-\(platform)-\(id)-\(timestamp)-\(NSUUID().uuidString)" + } } diff --git a/Test/Test Utilities/TestUtilities.swift b/Test/Test Utilities/TestUtilities.swift index 8b805fc3e..d8eb1c0c1 100644 --- a/Test/Test Utilities/TestUtilities.swift +++ b/Test/Test Utilities/TestUtilities.swift @@ -50,26 +50,6 @@ let testTimeout = DispatchTimeInterval.seconds(20) let testResourcesPath = "ably-common/test-resources/" let echoServerAddress = "https://echo.ably.io/createJWT" -func uniqueChannelName(for test: Test, - prefix: String = "", - timestamp: TimeInterval = Date.timeIntervalSinceReferenceDate) -> String { - let platform: String -#if targetEnvironment(macCatalyst) - platform = "macCatalyst" -#elseif os(OSX) - platform = "OSX" -#elseif os(iOS) - platform = "iOS" -#elseif os(tvOS) - platform = "tvOS" -#elseif os(watchOS) - platform = "watchOS" -#else - platform = "Unknown" -#endif - return "\(prefix)-\(platform)-\(test.id)-\(timestamp)-\(NSUUID().uuidString)" -} - /// Common test utilities. class AblyTests { enum Error: Swift.Error { diff --git a/Test/Tests/AuthTests.swift b/Test/Tests/AuthTests.swift index 172ff2a45..e53b51baa 100644 --- a/Test/Tests/AuthTests.swift +++ b/Test/Tests/AuthTests.swift @@ -90,7 +90,7 @@ class AuthTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { _ in + client.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { _ in done() } } @@ -127,7 +127,7 @@ class AuthTests: XCTestCase { clientHTTP.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - clientHTTP.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { _ in + clientHTTP.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { _ in done() } } @@ -146,7 +146,7 @@ class AuthTests: XCTestCase { clientHTTPS.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - clientHTTPS.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { _ in + clientHTTPS.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { _ in done() } } @@ -168,7 +168,7 @@ class AuthTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { _ in + client.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { _ in done() } } @@ -244,7 +244,7 @@ class AuthTests: XCTestCase { let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) testHTTPExecutor.simulateIncomingServerErrorOnNextRequest(ARTErrorCode.tokenRevoked.intValue, description: "token revoked") waitUntil(timeout: testTimeout) { done in @@ -278,7 +278,7 @@ class AuthTests: XCTestCase { XCTAssertNil(realtime.internal.options.authCallback) XCTAssertNil(realtime.internal.options.authUrl) - let channel = realtime.channels.get(uniqueChannelName(for: test)) + let channel = realtime.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout.multiplied(by: 2)) { done in realtime.connect() @@ -310,7 +310,7 @@ class AuthTests: XCTestCase { let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) testHTTPExecutor.simulateIncomingServerErrorOnNextRequest(ARTErrorCode.tokenRevoked.intValue, description: "token revoked") @@ -338,7 +338,7 @@ class AuthTests: XCTestCase { let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) testHTTPExecutor.setListenerAfterRequest { _ in testHTTPExecutor.simulateIncomingServerErrorOnNextRequest(ARTErrorCode.tokenRevoked.intValue, description: "token revoked") @@ -459,7 +459,7 @@ class AuthTests: XCTestCase { rest.internal.httpExecutor = proxyHTTPExecutor waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test)).history { _, error in + rest.channels.get(test.uniqueChannelName()).history { _, error in guard let error = error else { fail("Error is nil"); done(); return } @@ -500,7 +500,7 @@ class AuthTests: XCTestCase { } waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test)).history { _, error in + rest.channels.get(test.uniqueChannelName()).history { _, error in guard let error = error else { fail("Error is nil"); done(); return } @@ -926,7 +926,7 @@ class AuthTests: XCTestCase { let state = stateChange.current let error = stateChange.reason if state == .connected, error == nil { - let currentChannel = client.channels.get(uniqueChannelName(for: test)) + let currentChannel = client.channels.get(test.uniqueChannelName()) currentChannel.subscribe { _ in done() } @@ -1125,7 +1125,7 @@ class AuthTests: XCTestCase { let rest = ARTRest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("foo", data: nil) { error in XCTAssertNil(error) @@ -1153,7 +1153,7 @@ class AuthTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { error in + client.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { error in if let e = error { XCTFail(e.localizedDescription) } @@ -1193,7 +1193,7 @@ class AuthTests: XCTestCase { } options.defaultTokenParams = ARTTokenParams(clientId: "tester") let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(client.auth.clientId, "john") waitUntil(timeout: testTimeout) { done in @@ -1870,7 +1870,7 @@ class AuthTests: XCTestCase { let rest = ARTRest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let message = ARTMessage(name: nil, data: "message without an explicit clientId") @@ -1903,7 +1903,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, clientId: nil) let rest = ARTRest(options: options) - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let message = ARTMessage(name: nil, data: "message with an explicit clientId", clientId: "john") @@ -1933,7 +1933,7 @@ class AuthTests: XCTestCase { let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let message = ARTMessage(name: nil, data: "no client") @@ -1967,7 +1967,7 @@ class AuthTests: XCTestCase { // Request a token with a wildcard '*' value clientId options.token = try getTestToken(for: test, clientId: "*") let rest = ARTRest(options: options) - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let message = ARTMessage(name: nil, data: "message with an explicit clientId", clientId: "john") @@ -2518,7 +2518,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.useTokenAuth = true let rest = ARTRest(options: options) - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "first check") { error in @@ -2584,7 +2584,7 @@ class AuthTests: XCTestCase { XCTAssertNotEqual(tokenDetails.token, testToken) XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) - publishTestMessage(rest, channelName: uniqueChannelName(for: test), completion: { error in + publishTestMessage(rest, channelName: test.uniqueChannelName(), completion: { error in XCTAssertNil(error) XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) XCTAssertEqual(rest.auth.tokenDetails?.token, tokenDetails.token) @@ -2609,7 +2609,7 @@ class AuthTests: XCTestCase { XCTAssertNotNil(tokenDetails.token) XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) - publishTestMessage(rest, channelName: uniqueChannelName(for: test), completion: { error in + publishTestMessage(rest, channelName: test.uniqueChannelName(), completion: { error in XCTAssertNil(error) XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) XCTAssertEqual(rest.auth.tokenDetails?.token, tokenDetails.token) @@ -3837,7 +3837,7 @@ class AuthTests: XCTestCase { options.token = initialToken let realtime = ARTRealtime(options: options) defer { realtime.dispose(); realtime.close() } - let channel = realtime.channels.get(uniqueChannelName(for: test)) + let channel = realtime.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -4451,7 +4451,7 @@ class AuthTests: XCTestCase { var originalTokenRequest: ARTTokenRequest! let tmpRest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() waitUntil(timeout: testTimeout) { done in let tokenParams = ARTTokenParams() tokenParams.clientId = "john" diff --git a/Test/Tests/DeltaCodecTests.swift b/Test/Tests/DeltaCodecTests.swift index 746ee1f45..439bc809b 100644 --- a/Test/Tests/DeltaCodecTests.swift +++ b/Test/Tests/DeltaCodecTests.swift @@ -32,7 +32,7 @@ class DeltaCodecTests: XCTestCase { "delta": "vcdiff", ] - let channel = client.channels.get(uniqueChannelName(for: test), options: channelOptions) + let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -81,7 +81,7 @@ class DeltaCodecTests: XCTestCase { defer { client.dispose(); client.close() } let channelOptions = ARTRealtimeChannelOptions() channelOptions.params = ["delta": "vcdiff"] - let channel = client.channels.get(uniqueChannelName(for: test), options: channelOptions) + let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -141,7 +141,7 @@ class DeltaCodecTests: XCTestCase { defer { client.dispose(); client.close() } let channelOptions = ARTRealtimeChannelOptions() channelOptions.params = ["delta": "vcdiff"] - let channel = client.channels.get(uniqueChannelName(for: test), options: channelOptions) + let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) waitUntil(timeout: testTimeout) { done in channel.attach { error in diff --git a/Test/Tests/ObjectLifetimesTests.swift b/Test/Tests/ObjectLifetimesTests.swift index 4b4f19159..8a64e57a8 100644 --- a/Test/Tests/ObjectLifetimesTests.swift +++ b/Test/Tests/ObjectLifetimesTests.swift @@ -86,7 +86,7 @@ class ObjectLifetimesTests: XCTestCase { XCTAssertNotNil(weakClient) defer { client?.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() waitUntil(timeout: testTimeout) { done in client!.channels.get(channelName).subscribe(attachCallback: { _ in client = nil @@ -105,7 +105,7 @@ class ObjectLifetimesTests: XCTestCase { var client: ARTRealtime? = ARTRealtime(options: options) weak var weakClient = client!.internal - var channel: ARTRealtimeChannel? = client!.channels.get(uniqueChannelName(for: test)) + var channel: ARTRealtimeChannel? = client!.channels.get(test.uniqueChannelName()) weak var weakChannel = channel!.internal waitUntil(timeout: testTimeout) { done in diff --git a/Test/Tests/PushAdminTests.swift b/Test/Tests/PushAdminTests.swift index 5d1663bf1..7fc3bdba8 100644 --- a/Test/Tests/PushAdminTests.swift +++ b/Test/Tests/PushAdminTests.swift @@ -227,7 +227,7 @@ class PushAdminTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let realtime = ARTRealtime(options: options) defer { realtime.dispose(); realtime.close() } - let channel = realtime.channels.get("pushenabled:\(uniqueChannelName(for: test))") // works with pure uniqueChannelName(for: test) as well + let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well let publishObject = ["transportType": "ablyChannel", "channel": channel.name, "ablyKey": options.key!, @@ -260,7 +260,7 @@ class PushAdminTests: XCTestCase { let test = Test() let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } - let channel = realtime.channels.get("pushenabled:\(uniqueChannelName(for: test))") // works with pure uniqueChannelName(for: test) as well + let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -288,7 +288,7 @@ class PushAdminTests: XCTestCase { let test = Test() let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } - let channel = realtime.channels.get("pushenabled:\(uniqueChannelName(for: test))") // works with pure uniqueChannelName(for: test) as well + let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -315,7 +315,7 @@ class PushAdminTests: XCTestCase { let test = Test() let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } - let channel = realtime.channels.get("pushenabled:\(uniqueChannelName(for: test))") // works with pure uniqueChannelName(for: test) as well + let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well waitUntil(timeout: testTimeout) { done in channel.attach { error in diff --git a/Test/Tests/PushChannelTests.swift b/Test/Tests/PushChannelTests.swift index 333ee7b94..59312ba43 100644 --- a/Test/Tests/PushChannelTests.swift +++ b/Test/Tests/PushChannelTests.swift @@ -31,7 +31,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) waitUntil(timeout: testTimeout) { done in - testEnvironment.rest.channels.get(uniqueChannelName(for: test)).push.subscribeDevice { error in + testEnvironment.rest.channels.get(test.uniqueChannelName()).push.subscribeDevice { error in guard let error = error else { fail("Error is nil"); done(); return } @@ -52,7 +52,7 @@ class PushChannelTests: XCTestCase { rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.push.subscribeDevice { error in XCTAssertNil(error) @@ -93,7 +93,7 @@ class PushChannelTests: XCTestCase { defer { rest.device.clientId = originalClientId } waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test)).push.subscribeClient { error in + rest.channels.get(test.uniqueChannelName()).push.subscribeClient { error in guard let error = error else { fail("Error is nil"); done(); return } @@ -114,7 +114,7 @@ class PushChannelTests: XCTestCase { rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.push.subscribeClient { error in XCTAssertNil(error) @@ -145,7 +145,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) waitUntil(timeout: testTimeout) { done in - testEnvironment.rest.channels.get(uniqueChannelName(for: test)).push.unsubscribeDevice { error in + testEnvironment.rest.channels.get(test.uniqueChannelName()).push.unsubscribeDevice { error in guard let error = error else { fail("Error is nil"); done(); return } @@ -166,7 +166,7 @@ class PushChannelTests: XCTestCase { rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.push.unsubscribeDevice { error in XCTAssertNil(error) @@ -205,7 +205,7 @@ class PushChannelTests: XCTestCase { defer { rest.device.clientId = originalClientId } waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test)).push.unsubscribeClient { error in + rest.channels.get(test.uniqueChannelName()).push.unsubscribeClient { error in guard let error = error else { fail("Error is nil"); done(); return } @@ -226,7 +226,7 @@ class PushChannelTests: XCTestCase { rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.push.unsubscribeClient { error in XCTAssertNil(error) @@ -258,7 +258,7 @@ class PushChannelTests: XCTestCase { "deviceId": "111", "channel": "aaa", ] - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in try? channel.push.listSubscriptions(params) { result, error in XCTAssertNil(error) @@ -287,7 +287,7 @@ class PushChannelTests: XCTestCase { "clientId": "tester", "channel": "aaa", ] - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in try? channel.push.listSubscriptions(params) { result, error in XCTAssertNil(error) @@ -311,7 +311,7 @@ class PushChannelTests: XCTestCase { let test = Test() let testEnvironment = TestEnvironment(test: test) - let channel = testEnvironment.rest.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.rest.channels.get(test.uniqueChannelName()) expect { try channel.push.listSubscriptions([:]) { _, _ in } }.to(throwError { (error: NSError) in XCTAssertEqual(error.code, ARTDataQueryError.missingRequiredFields.rawValue) }) @@ -325,7 +325,7 @@ class PushChannelTests: XCTestCase { "deviceId": "x", "clientId": "y", ] - let channel = testEnvironment.rest.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.rest.channels.get(test.uniqueChannelName()) expect { try channel.push.listSubscriptions(params) { _, _ in } }.to(throwError { (error: NSError) in XCTAssertEqual(error.code, ARTDataQueryError.invalidParameters.rawValue) }) @@ -347,7 +347,7 @@ class PushChannelTests: XCTestCase { rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } - let channel = rest.channels.get("pushenabled:\(uniqueChannelName(for: test))") + let channel = rest.channels.get("pushenabled:\(test.uniqueChannelName())") waitUntil(timeout: testTimeout) { done in channel.push.subscribeClient { error in XCTAssertNil(error) diff --git a/Test/Tests/ReadmeExamplesTests.swift b/Test/Tests/ReadmeExamplesTests.swift index b077b98bb..07e03a910 100644 --- a/Test/Tests/ReadmeExamplesTests.swift +++ b/Test/Tests/ReadmeExamplesTests.swift @@ -48,7 +48,7 @@ class ReadmeExamplesTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.subscribe { message in print(message.name as Any) @@ -69,7 +69,7 @@ class ReadmeExamplesTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.history { messagesPage, _ in let messagesPage = messagesPage! @@ -93,7 +93,7 @@ class ReadmeExamplesTests: XCTestCase { client.connection.on { stateChange in if stateChange.current == .connected { - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.presence.enter("john.doe") { _ in channel.presence.get { _, _ in @@ -110,7 +110,7 @@ class ReadmeExamplesTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.presence.history { presencePage, _ in let presencePage = presencePage! @@ -128,7 +128,7 @@ class ReadmeExamplesTests: XCTestCase { func test__009__testMakeRestClientAndChannel() { let test = Test() let client = ARTRest(key: "xxxx:xxxx") - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) _ = channel } @@ -136,7 +136,7 @@ class ReadmeExamplesTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.publish("myEvent", data: "Hello!") } @@ -145,7 +145,7 @@ class ReadmeExamplesTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.history { messagesPage, _ in let messagesPage = messagesPage! @@ -162,7 +162,7 @@ class ReadmeExamplesTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.presence.get { membersPage, _ in let membersPage = membersPage! @@ -179,7 +179,7 @@ class ReadmeExamplesTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.presence.history { presencePage, _ in let presencePage = presencePage! @@ -207,7 +207,7 @@ class ReadmeExamplesTests: XCTestCase { func test__015__testFetchingStats() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - client.channels.get(uniqueChannelName(for: test)).publish("foo", data: "bar") { _ in + client.channels.get(test.uniqueChannelName()).publish("foo", data: "bar") { _ in client.stats { statsPage, _ in let statsPage = statsPage! print(statsPage.items.first as Any) diff --git a/Test/Tests/RealtimeClientChannelTests.swift b/Test/Tests/RealtimeClientChannelTests.swift index 67e3ed616..918374298 100644 --- a/Test/Tests/RealtimeClientChannelTests.swift +++ b/Test/Tests/RealtimeClientChannelTests.swift @@ -161,7 +161,7 @@ class RealtimeClientChannelTests: XCTestCase { let client1 = AblyTests.newRealtime(options).client defer { client1.dispose(); client1.close() } - let roomName = uniqueChannelName(for: test, prefix: "room") + let roomName = test.uniqueChannelName(prefix: "room") let channel1 = client1.channels.get(roomName) @@ -230,7 +230,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(channel.internal.statesEventEmitter).to(beAKindOf(ARTEventEmitter.self)) var channelOnMethodCalled = false @@ -298,7 +298,7 @@ class RealtimeClientChannelTests: XCTestCase { options.token = try getTestToken(for: test, capability: "{\"secret\":[\"subscribe\"]}") let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.on { stateChange in @@ -329,7 +329,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -354,7 +354,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -394,7 +394,7 @@ class RealtimeClientChannelTests: XCTestCase { options.logLevel = .debug let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.on { stateChange in XCTAssertNotEqual(stateChange.current, stateChange.previous) @@ -432,7 +432,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) channel.attach() @@ -445,7 +445,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let pmError = AblyTests.newErrorProtocolMessage() waitUntil(timeout: testTimeout) { done in @@ -468,7 +468,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.on { stateChange in @@ -504,7 +504,7 @@ class RealtimeClientChannelTests: XCTestCase { options.tokenDetails = try getTestTokenDetails(for: test, ttl: 5.0) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.on { stateChange in @@ -542,7 +542,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.once(.attached) { stateChange in @@ -583,7 +583,7 @@ class RealtimeClientChannelTests: XCTestCase { client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.attached] @@ -611,7 +611,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -647,7 +647,7 @@ class RealtimeClientChannelTests: XCTestCase { var channel0Name = "" for i in 0 ..< 100 { // We need a few channels to trigger iterator invalidation. - let channelName = uniqueChannelName(for: test, prefix: "channel\(i)") + let channelName = test.uniqueChannelName(prefix: "channel\(i)") if i == 0 { channel0Name = channelName } let channel = client.channels.get(channelName) channel.attach() // No need to wait; ATTACHING state is good enough. @@ -677,7 +677,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in XCTAssertEqual(client.connection.state, .initialized) channel.publish(nil, data: "message") { error in @@ -710,7 +710,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } client.internal.setReachabilityClass(TestReachability.self) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in @@ -765,7 +765,7 @@ class RealtimeClientChannelTests: XCTestCase { defer { client.dispose(); client.close() } expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.attached] @@ -783,7 +783,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -804,7 +804,7 @@ class RealtimeClientChannelTests: XCTestCase { client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.attached] @@ -821,7 +821,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) client.internal.onSuspended() @@ -844,7 +844,7 @@ class RealtimeClientChannelTests: XCTestCase { var channel0Name = "" for i in 0 ..< 100 { // We need a few channels to trigger iterator invalidation. - let channelName = uniqueChannelName(for: test, prefix: "channel\(i)") + let channelName = test.uniqueChannelName(prefix: "channel\(i)") if i == 0 { channel0Name = channelName } let channel = client.channels.get(channelName) channel.attach() // No need to wait; ATTACHING state is good enough. @@ -873,7 +873,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -901,7 +901,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -940,7 +940,7 @@ class RealtimeClientChannelTests: XCTestCase { let ttlHookToken = client.overrideConnectionStateTTL(3.0) defer { ttlHookToken.remove() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -997,7 +997,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.once(.detached) { _ in fail("Should not reach the DETACHED state") @@ -1029,7 +1029,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach { errorInfo in XCTAssertNil(errorInfo) @@ -1059,7 +1059,7 @@ class RealtimeClientChannelTests: XCTestCase { options.token = try getTestToken(for: test, key: options.key!, capability: "{\"restricted\":[\"*\"]}") let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) @@ -1085,7 +1085,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1122,7 +1122,7 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.closed] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) client.close() XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closing) @@ -1140,7 +1140,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) client.close() expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.closed), timeout: testTimeout) @@ -1158,7 +1158,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) client.internal.onSuspended() XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.suspended) waitUntil(timeout: testTimeout) { done in @@ -1174,7 +1174,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) client.internal.onError(AblyTests.newErrorProtocolMessage()) XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.failed) waitUntil(timeout: testTimeout) { done in @@ -1194,7 +1194,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(client.connection.state, .initialized) waitUntil(timeout: testTimeout) { done in channel.on(.attached) { stateChange in @@ -1215,7 +1215,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connect() @@ -1235,7 +1235,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -1264,7 +1264,7 @@ class RealtimeClientChannelTests: XCTestCase { expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) @@ -1282,7 +1282,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() waitUntil(timeout: testTimeout) { done in @@ -1315,7 +1315,7 @@ class RealtimeClientChannelTests: XCTestCase { } transport.actionsIgnored += [.attached] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { errorInfo in XCTAssertNotNil(errorInfo) @@ -1346,7 +1346,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { errorInfo in @@ -1362,7 +1362,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach() @@ -1380,7 +1380,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1399,7 +1399,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) var attachedCount = 0 channel.on(.attached) { stateChange in @@ -1432,7 +1432,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -1477,7 +1477,7 @@ class RealtimeClientChannelTests: XCTestCase { options.testOptions.realtimeRequestTimeout = 1.0 let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -1510,7 +1510,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -1552,7 +1552,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // Initialized XCTAssertEqual(channel.internal.attachResume, attachResumeExpectedValues[channel.state]) @@ -1594,7 +1594,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) @@ -1645,7 +1645,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) channel.detach { errorInfo in @@ -1678,7 +1678,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -1730,7 +1730,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) @@ -1763,7 +1763,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) client.internal.onError(AblyTests.newErrorProtocolMessage()) XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.failed) @@ -1788,7 +1788,7 @@ class RealtimeClientChannelTests: XCTestCase { expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) channel.detach() @@ -1806,7 +1806,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1826,7 +1826,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1848,7 +1848,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1878,7 +1878,7 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.detached] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1914,7 +1914,7 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.closed] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1934,7 +1934,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -1957,7 +1957,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach() XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) @@ -1979,7 +1979,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connect() @@ -2000,7 +2000,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2023,7 +2023,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -2059,7 +2059,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let data = ["value": 1] - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) let restChannel = rest.channels.get(channelName) @@ -2115,7 +2115,7 @@ class RealtimeClientChannelTests: XCTestCase { let error = stateChange.reason XCTAssertNil(error) if state == .connected { - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.on { stateChange in if stateChange.current == .attached { channel.publish(nil, data: "message") { errorInfo in @@ -2133,7 +2133,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__068__Channel__publish__should_invoke_callback__upon_failure() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelname = uniqueChannelName(for: test) + let channelname = test.uniqueChannelName() options.token = try getTestToken(for: test, key: options.key, capability: "{ \"\(options.testOptions.channelNamePrefix!)-\(channelname)\":[\"subscribe\"] }") let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } @@ -2168,8 +2168,8 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelToSucceedName = uniqueChannelName(for: test, prefix: "channelToSucceed") - let channelToFailName = uniqueChannelName(for: test, prefix: "channelToFail") + let channelToSucceedName = test.uniqueChannelName(prefix: "channelToSucceed") + let channelToFailName = test.uniqueChannelName(prefix: "channelToFail") options.token = try getTestToken(for: test, key: options.key, capability: "{ \"\(options.testOptions.channelNamePrefix!)-\(channelToSucceedName)\":[\"subscribe\", \"publish\"], \"\(options.testOptions.channelNamePrefix!)-\(channelToFailName)\":[\"subscribe\"] }") @@ -2226,7 +2226,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -2250,7 +2250,7 @@ class RealtimeClientChannelTests: XCTestCase { done() } } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) @@ -2269,7 +2269,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { _ in done() @@ -2298,7 +2298,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in done() @@ -2326,7 +2326,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { _ in done() @@ -2366,7 +2366,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__076__Channel__publish__Connection_state_conditions__the_message__should_be_queued_and_delivered_as_soon_as_the_connection_state_returns_to_CONNECTED_if_the_connection_is__INITIALIZED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in XCTAssertEqual(rtl6c2TestsClient.connection.state, ARTRealtimeConnectionState.initialized) @@ -2380,7 +2380,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__077__Channel__publish__Connection_state_conditions__the_message__should_be_queued_and_delivered_as_soon_as_the_connection_state_returns_to_CONNECTED_if_the_connection_is__CONNECTING() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in rtl6c2TestsClient.connect() @@ -2394,7 +2394,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__078__Channel__publish__Connection_state_conditions__the_message__should_be_queued_and_delivered_as_soon_as_the_connection_state_returns_to_CONNECTED_if_the_connection_is__DISCONNECTED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) rtl6c2TestsClient.connect() expect(rtl6c2TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2411,7 +2411,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__079__Channel__publish__Connection_state_conditions__the_message__should_NOT_be_queued_instead_it_should_be_published_if_the_channel_is__INITIALIZED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) rtl6c2TestsClient.connect() XCTAssertEqual(rtl6c2TestsChannel.state, ARTRealtimeChannelState.initialized) @@ -2429,7 +2429,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__080__Channel__publish__Connection_state_conditions__the_message__should_NOT_be_queued_instead_it_should_be_published_if_the_channel_is__ATTACHING() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) rtl6c2TestsClient.connect() expect(rtl6c2TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2447,7 +2447,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__081__Channel__publish__Connection_state_conditions__the_message__should_NOT_be_queued_instead_it_should_be_published_if_the_channel_is__ATTACHED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in rtl6c2TestsChannel.attach { error in @@ -2499,7 +2499,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__082__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the__connection_is_SUSPENDED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2514,7 +2514,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__083__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the__connection_is_CLOSING() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2529,7 +2529,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__084__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the__connection_is_CLOSED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2544,7 +2544,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__085__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the__connection_is_FAILED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2559,7 +2559,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__086__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the__channel_is_SUSPENDED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() rtl6c4TestsChannel.attach() @@ -2575,7 +2575,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__087__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the__channel_is_FAILED() throws { let test = Test() - try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: uniqueChannelName(for: test)) + try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() rtl6c4TestsChannel.attach() @@ -2596,7 +2596,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let protocolError = AblyTests.newErrorProtocolMessage() XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) @@ -2624,7 +2624,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // Test that the initially queued messages are sent together. @@ -2683,7 +2683,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // This amount of messages would be beyond maxMessageSize, if bundled together let messagesToBeSent = 2000 @@ -2716,7 +2716,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let clientIDs = ["client1", "client2", "client3"] waitUntil(timeout: testTimeout) { done in @@ -2741,7 +2741,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) @@ -2767,7 +2767,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) var messages = [ARTMessage]() for i in 1 ... 3 { messages.append(ARTMessage(name: "name\(i)", data: "data\(i)", clientId: "clientId\(i)")) @@ -2797,8 +2797,8 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelOne = client.channels.get(uniqueChannelName(for: test, prefix: "bundlingOne")) - let channelTwo = client.channels.get(uniqueChannelName(for: test, prefix: "bundlingTwo")) + let channelOne = client.channels.get(test.uniqueChannelName(prefix: "bundlingOne")) + let channelTwo = client.channels.get(test.uniqueChannelName(prefix: "bundlingTwo")) channelTwo.publish("2a", data: ["expectedBundle": 0]) channelOne.publish("a", data: ["expectedBundle": 1]) @@ -2864,7 +2864,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test, prefix: "idempotentRealtimePublishing")) + let channel = client.channels.get(test.uniqueChannelName(prefix: "idempotentRealtimePublishing")) waitUntil(timeout: testTimeout) { done in channel.once(.attached) { stateChange in @@ -2905,7 +2905,7 @@ class RealtimeClientChannelTests: XCTestCase { XCTAssertNil(client.auth.clientId) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) var resultClientId: String? @@ -2932,7 +2932,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.subscribe { message in @@ -2953,7 +2953,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) typealias JSONObject = NSDictionary var result = [JSONObject]() @@ -2974,7 +2974,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let expectedResult = "string_data" var result: String? @@ -2996,7 +2996,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) let expectedObject = ["data": "message", "connectionId": client.connection.id!] @@ -3035,7 +3035,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) let expectedObject = ["name": "click", "connectionId": client.connection.id!] @@ -3074,7 +3074,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) let expectedObject = ["name": "click", "data": "message", "connectionId": client.connection.id!] @@ -3110,7 +3110,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let message = ARTMessage(name: nil, data: "message") XCTAssertNil(message.clientId) @@ -3139,7 +3139,7 @@ class RealtimeClientChannelTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let message = ARTMessage(name: nil, data: "message", clientId: options.clientId!) var resultClientId: String? @@ -3166,7 +3166,7 @@ class RealtimeClientChannelTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([ARTMessage(name: nil, data: "message", clientId: "tester")]) { error in @@ -3192,7 +3192,7 @@ class RealtimeClientChannelTests: XCTestCase { } let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let message = ARTMessage(name: nil, data: "message", clientId: "john") waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) @@ -3216,7 +3216,7 @@ class RealtimeClientChannelTests: XCTestCase { } let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let message = ARTMessage(name: nil, data: "message", clientId: "tester") waitUntil(timeout: testTimeout) { done in channel.publish([message]) { error in @@ -3231,7 +3231,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) @@ -3256,7 +3256,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) var counter = 0 @@ -3278,7 +3278,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) var counter = 0 @@ -3301,7 +3301,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let publishedMessage = ARTMessage(name: "foo", data: "bar") @@ -3328,7 +3328,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.subscribe { _ in } @@ -3341,7 +3341,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.internal.onError(AblyTests.newErrorProtocolMessage()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) @@ -3361,12 +3361,12 @@ class RealtimeClientChannelTests: XCTestCase { func test__112__Channel__subscribe__should_deliver_the_message_even_if_there_is_an_error_while_decoding__using_crypto_data_128() throws { let test = Test() - try testHandlesDecodingErrorInFixture("crypto-data-128", for: test, channelName: uniqueChannelName(for: test)) + try testHandlesDecodingErrorInFixture("crypto-data-128", for: test, channelName: test.uniqueChannelName()) } func test__113__Channel__subscribe__should_deliver_the_message_even_if_there_is_an_error_while_decoding__using_crypto_data_256() throws { let test = Test() - try testHandlesDecodingErrorInFixture("crypto-data-256", for: test, channelName: uniqueChannelName(for: test)) + try testHandlesDecodingErrorInFixture("crypto-data-256", for: test, channelName: test.uniqueChannelName()) } // RTL7e @@ -3381,7 +3381,7 @@ class RealtimeClientChannelTests: XCTestCase { defer { client.dispose(); client.close() } let channelOptions = ARTRealtimeChannelOptions(cipher: ["key": ARTCrypto.generateRandomKey()] as ARTCipherParamsCompatible) - let channel = client.channels.get(uniqueChannelName(for: test), options: channelOptions) + let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) let expectedMessage = ["key": 1] let expectedData = try JSONSerialization.data(withJSONObject: expectedMessage, options: JSONSerialization.WritingOptions(rawValue: 0)) @@ -3428,7 +3428,7 @@ class RealtimeClientChannelTests: XCTestCase { let client2 = ARTRealtime(options: options) defer { client2.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) let channel2 = client2.channels.get(channelName) @@ -3457,7 +3457,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let listener = channel.subscribe { _ in @@ -3480,7 +3480,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let eventAListener = channel.subscribe("eventA") { _ in @@ -3509,8 +3509,8 @@ class RealtimeClientChannelTests: XCTestCase { let realtime = ARTRealtime(options: options) defer { realtime.close() } - let channelRest = rest.channels.get(uniqueChannelName(for: test)) - let channelRealtime = realtime.channels.get(uniqueChannelName(for: test)) + let channelRest = rest.channels.get(test.uniqueChannelName()) + let channelRealtime = realtime.channels.get(test.uniqueChannelName()) var restChannelHistoryMethodWasCalled = false @@ -3563,7 +3563,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTRealtimeHistoryQuery() query.untilAttach = true @@ -3581,12 +3581,12 @@ class RealtimeClientChannelTests: XCTestCase { func test__125__Channel__history__supports_the_param_untilAttach__where_value_is_true__should_pass_the_querystring_param_fromSerial_with_the_serial_number_assigned_to_the_channel() throws { let test = Test() - try testWithUntilAttach(true, for: test, channelName: uniqueChannelName(for: test)) + try testWithUntilAttach(true, for: test, channelName: test.uniqueChannelName()) } func test__126__Channel__history__supports_the_param_untilAttach__where_value_is_false__should_pass_the_querystring_param_fromSerial_with_the_serial_number_assigned_to_the_channel() throws { let test = Test() - try testWithUntilAttach(true, for: test, channelName: uniqueChannelName(for: test)) + try testWithUntilAttach(true, for: test, channelName: test.uniqueChannelName()) } func test__127__Channel__history__supports_the_param_untilAttach__should_retrieve_messages_prior_to_the_moment_that_the_channel_was_attached() throws { @@ -3599,7 +3599,7 @@ class RealtimeClientChannelTests: XCTestCase { let client2 = ARTRealtime(options: options) defer { client2.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) channel1.attach() @@ -3663,7 +3663,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.close() } - let channel = realtime.channels.get(uniqueChannelName(for: test)) + let channel = realtime.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { errorInfo in @@ -3698,7 +3698,7 @@ class RealtimeClientChannelTests: XCTestCase { let client2 = ARTRealtime(options: options) defer { client2.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) channel1.attach() @@ -3749,7 +3749,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -3811,7 +3811,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -3865,7 +3865,7 @@ class RealtimeClientChannelTests: XCTestCase { fail("TestProxyTransport is not set"); return } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // Timeout transport.actionsIgnored += [.attached] @@ -3908,7 +3908,7 @@ class RealtimeClientChannelTests: XCTestCase { options.testOptions.realtimeRequestTimeout = 1.0 let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -3968,7 +3968,7 @@ class RealtimeClientChannelTests: XCTestCase { options.channelRetryTimeout = 1.0 let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let detachedMessageWithError = AblyTests.newErrorProtocolMessage() detachedMessageWithError.action = .detached @@ -4021,7 +4021,7 @@ class RealtimeClientChannelTests: XCTestCase { expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) @@ -4060,7 +4060,7 @@ class RealtimeClientChannelTests: XCTestCase { options.testOptions.realtimeRequestTimeout = 1.0 let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -4113,7 +4113,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -4149,7 +4149,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -4218,7 +4218,7 @@ class RealtimeClientChannelTests: XCTestCase { "delta": "vcdiff", ] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) channel.once(.attaching) { _ in @@ -4261,7 +4261,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let channelOptions = ARTRealtimeChannelOptions() channelOptions.modes = [.subscribe] @@ -4284,7 +4284,7 @@ class RealtimeClientChannelTests: XCTestCase { options.token = try getTestToken(for: test, capability: "{\"secret\":[\"subscribe\"]}") // access denied let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in @@ -4333,7 +4333,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in @@ -4387,7 +4387,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in @@ -4423,7 +4423,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.close(); client.dispose() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let m1 = ARTMessage(name: "m1", data: "d1") let m2 = ARTMessage(name: "m2", data: "d2") @@ -4480,7 +4480,7 @@ class RealtimeClientChannelTests: XCTestCase { clientReceiver.connect() let key = ARTCrypto.generateRandomKey() - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let sender = clientSender.channels.get(channelName, options: ARTRealtimeChannelOptions(cipherKey: key as ARTCipherKeyCompatible)) let receiver = clientReceiver.channels.get(channelName, options: ARTRealtimeChannelOptions(cipherKey: key as ARTCipherKeyCompatible)) @@ -4557,7 +4557,7 @@ class RealtimeClientChannelTests: XCTestCase { options.testOptions.realtimeRequestTimeout = 1.0 let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) guard let transport = client.internal.transport as? TestProxyTransport else { fail("TestProxyTransport is not set"); return @@ -4591,7 +4591,7 @@ class RealtimeClientChannelTests: XCTestCase { p.id = "protocolId" let m = ARTMessage(name: nil, data: "message without ID") p.messages = [m] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { _ in done() diff --git a/Test/Tests/RealtimeClientChannelsTests.swift b/Test/Tests/RealtimeClientChannelsTests.swift index 4c2233926..7cb29daa3 100644 --- a/Test/Tests/RealtimeClientChannelsTests.swift +++ b/Test/Tests/RealtimeClientChannelsTests.swift @@ -17,9 +17,9 @@ class RealtimeClientChannelsTests: XCTestCase { defer { client.dispose(); client.close() } var disposable = [String]() - let channelName1 = uniqueChannelName(for: test, prefix: "1") - let channelName2 = uniqueChannelName(for: test, prefix: "2") - let channelName3 = uniqueChannelName(for: test, prefix: "3") + let channelName1 = test.uniqueChannelName(prefix: "1") + let channelName2 = test.uniqueChannelName(prefix: "2") + let channelName3 = test.uniqueChannelName(prefix: "3") disposable.append(client.channels.get(channelName1).name) disposable.append(client.channels.get(channelName2).name) @@ -44,7 +44,7 @@ class RealtimeClientChannelsTests: XCTestCase { defer { client.dispose(); client.close() } XCTAssertEqual(client.channels.internal.collection.count, 0) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) XCTAssertEqual(channel.name, "\(options.testOptions.channelNamePrefix!)-\(channelName)") @@ -59,7 +59,7 @@ class RealtimeClientChannelsTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let options = ARTRealtimeChannelOptions() - let channel = client.channels.get(uniqueChannelName(for: test), options: options) + let channel = client.channels.get(test.uniqueChannelName(), options: options) XCTAssertTrue(channel.options === options) } @@ -68,7 +68,7 @@ class RealtimeClientChannelsTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() XCTAssertNil(client.channels.get(channelName).options) let options = ARTRealtimeChannelOptions() let channel = client.channels.get(channelName, options: options) @@ -82,7 +82,7 @@ class RealtimeClientChannelsTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) channel.subscribe { _ in fail("shouldn't happen") diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index 03a1a16c3..d044cf06b 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -815,7 +815,7 @@ class RealtimeClientConnectionTests: XCTestCase { defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in - publishFirstTestMessage(client, channelName: uniqueChannelName(for: test), completion: { error in + publishFirstTestMessage(client, channelName: test.uniqueChannelName(), completion: { error in XCTAssertNil(error) done() }) @@ -850,7 +850,7 @@ class RealtimeClientConnectionTests: XCTestCase { let error = stateChange.reason XCTAssertNil(error) if state == .connected { - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach { error in XCTAssertNil(error) channel.presence.enterClient("client_string", data: nil, callback: { errorInfo in @@ -879,7 +879,7 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() options.token = try getTestToken(for: test, key: options.key, capability: "{ \"\(options.testOptions.channelNamePrefix!)-\(channelName)\":[\"subscribe\"] }") options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() @@ -923,7 +923,7 @@ class RealtimeClientConnectionTests: XCTestCase { let error = stateChange.reason XCTAssertNil(error) if state == .connected { - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach { error in XCTAssertNil(error) channel.presence.enterClient("invalid", data: nil, callback: { errorInfo in @@ -960,7 +960,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() waitUntil(timeout: testTimeout) { done in @@ -1026,7 +1026,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in XCTAssertNil(error) @@ -1111,7 +1111,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in XCTAssertNil(error) @@ -1204,7 +1204,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.ack, .nack] @@ -1243,7 +1243,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.ack, .nack] @@ -1274,7 +1274,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.ack, .nack] @@ -1497,7 +1497,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.dispose() client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(client.connection.serial, -1) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -1530,7 +1530,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.dispose() client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) // Attach first to avoid bundling publishes in the same ProtocolMessage. @@ -2481,7 +2481,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client1 = ARTRealtime(options: options) defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) var states = [ARTRealtimeConnectionState]() @@ -2589,7 +2589,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) let expectedConnectionId = client.connection.id @@ -2618,7 +2618,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2675,7 +2675,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -2722,7 +2722,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -2759,7 +2759,7 @@ class RealtimeClientConnectionTests: XCTestCase { restOptions.testOptions.channelNamePrefix = options.testOptions.channelNamePrefix let rest = ARTRest(options: restOptions) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -2836,7 +2836,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client1 = ARTRealtime(options: options) defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) let client2 = ARTRealtime(options: options) @@ -2883,7 +2883,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = ARTRealtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -2914,7 +2914,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) var resumed = false waitUntil(timeout: testTimeout) { done in @@ -3015,7 +3015,7 @@ class RealtimeClientConnectionTests: XCTestCase { ttlAndIdleIntervalPassedTestsClient = AblyTests.newRealtime(options).client ttlAndIdleIntervalPassedTestsClient.internal.shouldImmediatelyReconnect = false defer { ttlAndIdleIntervalPassedTestsClient.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = ttlAndIdleIntervalPassedTestsClient.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -3209,7 +3209,7 @@ class RealtimeClientConnectionTests: XCTestCase { let clientSend = ARTRealtime(options: options) defer { clientSend.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channelSend = clientSend.channels.get(channelName) let clientReceive = ARTRealtime(options: options) @@ -3256,7 +3256,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) client.connection.once(.connected) { _ in @@ -3412,7 +3412,7 @@ class RealtimeClientConnectionTests: XCTestCase { let testEnvironment = AblyTests.newRealtime(options) let client = testEnvironment.client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) testEnvironment.transportFactory.fakeNetworkResponse = .hostUnreachable @@ -3463,7 +3463,7 @@ class RealtimeClientConnectionTests: XCTestCase { let testEnvironment = AblyTests.newRealtime(options) let client = testEnvironment.client defer { client.dispose(); client.close() } - client.channels.get(uniqueChannelName(for: test)) + client.channels.get(test.uniqueChannelName()) testEnvironment.transportFactory.fakeNetworkResponse = .hostUnreachable @@ -3501,7 +3501,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - client.channels.get(uniqueChannelName(for: test)) + client.channels.get(test.uniqueChannelName()) transportFactory.fakeNetworkResponse = .hostUnreachable @@ -3546,7 +3546,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - client.channels.get(uniqueChannelName(for: test)) + client.channels.get(test.uniqueChannelName()) transportFactory.fakeNetworkResponse = .hostUnreachable @@ -3584,17 +3584,17 @@ class RealtimeClientConnectionTests: XCTestCase { func skipped__test__097__Connection__Host_Fallback__should_use_an_alternative_host_when___hostUnreachable() { let test = Test() - testUsesAlternativeHostOnResponse(.hostUnreachable, channelName: uniqueChannelName(for: test)) + testUsesAlternativeHostOnResponse(.hostUnreachable, channelName: test.uniqueChannelName()) } func skipped__test__098__Connection__Host_Fallback__should_use_an_alternative_host_when___requestTimeout_timeout__0_1_() { let test = Test() - testUsesAlternativeHostOnResponse(.requestTimeout(timeout: 0.1), channelName: uniqueChannelName(for: test)) + testUsesAlternativeHostOnResponse(.requestTimeout(timeout: 0.1), channelName: test.uniqueChannelName()) } func skipped__test__099__Connection__Host_Fallback__should_use_an_alternative_host_when___hostInternalError_code__501_() { let test = Test() - testUsesAlternativeHostOnResponse(.hostInternalError(code: 501), channelName: uniqueChannelName(for: test)) + testUsesAlternativeHostOnResponse(.hostInternalError(code: 501), channelName: test.uniqueChannelName()) } func test__100__Connection__Host_Fallback__should_move_to_disconnected_when_there_s_no_internet__with_NSPOSIXErrorDomain_with_code_57() throws { @@ -3620,7 +3620,7 @@ class RealtimeClientConnectionTests: XCTestCase { let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) transportFactory.fakeNetworkResponse = .host400BadRequest @@ -3655,7 +3655,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - client.channels.get(uniqueChannelName(for: test)) + client.channels.get(test.uniqueChannelName()) transportFactory.fakeNetworkResponse = .hostUnreachable @@ -3710,7 +3710,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - client.channels.get(uniqueChannelName(for: test)) + client.channels.get(test.uniqueChannelName()) let testHttpExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.rest.httpExecutor = testHttpExecutor @@ -3785,7 +3785,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - client.channels.get(uniqueChannelName(for: test)) + client.channels.get(test.uniqueChannelName()) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) @@ -3836,7 +3836,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - client.channels.get(uniqueChannelName(for: test)) + client.channels.get(test.uniqueChannelName()) let testHttpExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.rest.httpExecutor = testHttpExecutor @@ -3906,7 +3906,7 @@ class RealtimeClientConnectionTests: XCTestCase { let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let testHttpExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.rest.httpExecutor = testHttpExecutor @@ -4023,7 +4023,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let transport = client.internal.transport as! TestProxyTransport waitUntil(timeout: testTimeout) { done in @@ -4061,7 +4061,7 @@ class RealtimeClientConnectionTests: XCTestCase { fail("TestProxyTransport is not setup"); return } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in transport.ignoreSends = true channel.attach { error in @@ -4091,7 +4091,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let transport = client.internal.transport as! TestProxyTransport expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -4249,7 +4249,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -4331,7 +4331,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -4577,7 +4577,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.useBinaryProtocol = false let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -4656,7 +4656,7 @@ class RealtimeClientConnectionTests: XCTestCase { realtimeSubscribeClientJSON.close() } - let realtimeSubscribeChannelMsgPack = realtimeSubscribeClientMsgPack.channels.get(uniqueChannelName(for: test)) + let realtimeSubscribeChannelMsgPack = realtimeSubscribeClientMsgPack.channels.get(test.uniqueChannelName()) let realtimeSubscribeChannelJSON = realtimeSubscribeClientJSON.channels.get(realtimeSubscribeChannelMsgPack.name) waitUntil(timeout: testTimeout) { done in @@ -4706,7 +4706,7 @@ class RealtimeClientConnectionTests: XCTestCase { let restPublishClientJSON = ARTRest(options: jsonOptions) let restRetrieveClient = ARTRest(options: jsonOptions) - let restPublishChannelMsgPack = restPublishClientMsgPack.channels.get(uniqueChannelName(for: test)) + let restPublishChannelMsgPack = restPublishClientMsgPack.channels.get(test.uniqueChannelName()) let restPublishChannelJSON = restPublishClientJSON.channels.get(restPublishChannelMsgPack.name) let messages = fixtures["messages"] as! [[String: Any]] diff --git a/Test/Tests/RealtimeClientPresenceTests.swift b/Test/Tests/RealtimeClientPresenceTests.swift index 1d2db0eed..ddb4c3d99 100644 --- a/Test/Tests/RealtimeClientPresenceTests.swift +++ b/Test/Tests/RealtimeClientPresenceTests.swift @@ -114,7 +114,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) @@ -140,7 +140,7 @@ class RealtimeClientPresenceTests: XCTestCase { } } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 250, options: options)] options.autoConnect = false @@ -175,7 +175,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -259,7 +259,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -321,7 +321,7 @@ class RealtimeClientPresenceTests: XCTestCase { func skipped__test__013__Presence__PresenceMap_has_existing_members_when_a_SYNC_is_started__should_ensure_that_members_no_longer_present_on_the_channel_are_removed_from_the_local_PresenceMap_once_the_sync_is_complete() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 2, options: options) @@ -394,7 +394,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) // Inject local members @@ -446,7 +446,7 @@ class RealtimeClientPresenceTests: XCTestCase { var clientSource: ARTRealtime! defer { clientSource.dispose(); clientSource.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() clientSource = AblyTests.addMembersSequentiallyToChannel(channelName, members: 250, options: options) let clientTarget = ARTRealtime(options: options) @@ -487,7 +487,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = AblyTests.newRealtime(options).client defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) // We want to make sure that the ENTER presence action that we publish // gets sent by Realtime as a PRESENCE protocol message, and not in the @@ -539,7 +539,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let listener = channel.presence.subscribe { _ in }! XCTAssertEqual(channel.internal.presenceEventEmitter.anyListeners.count, 1) @@ -555,7 +555,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let protocolError = AblyTests.newErrorProtocolMessage() @@ -575,7 +575,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) channel.presence.enterClient("user", data: nil) { error in @@ -615,7 +615,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.once(.attaching) { _ in @@ -633,7 +633,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) channel.presence.enterClient("user", data: nil) { error in @@ -673,7 +673,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = AblyTests.newRealtime(options).client defer { client1.dispose(); client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -727,7 +727,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -759,7 +759,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__023__Presence__Channel_state_change_side_effects__channel_enters_the_SUSPENDED_state__should_maintain_the_PresenceMap_and_any_members_present_before_and_after_the_sync_should_not_emit_presence_events() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 3, options: options) @@ -850,7 +850,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = ARTRealtime(options: options) defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) let client2 = ARTRealtime(options: options) @@ -877,7 +877,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let listener = channel.presence.subscribe(.present) { _ in }! XCTAssertEqual(channel.internal.presenceEventEmitter.listeners.count, 1) @@ -892,7 +892,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) channel.presence.subscribe { _ in } @@ -913,7 +913,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.internal.onError(AblyTests.newErrorProtocolMessage()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) @@ -934,7 +934,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let error = AblyTests.newErrorProtocolMessage() @@ -962,7 +962,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = ARTRealtime(options: options) defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) let client2 = ARTRealtime(options: options) @@ -1005,7 +1005,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = ARTRealtime(options: options) defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) let client2 = ARTRealtime(options: options) @@ -1034,7 +1034,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = ARTRealtime(options: options) defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) let client2 = ARTRealtime(options: options) @@ -1063,7 +1063,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // We want to make sure that the ENTER presence action that we publish // gets sent by Realtime as a PRESENCE protocol message, and not in the // channel’s initial post-attach SYNC. So, we wait for any initial SYNC @@ -1100,7 +1100,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected)) @@ -1119,7 +1119,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: options) options.clientId = "*" defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected)) @@ -1138,7 +1138,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { _ in @@ -1163,7 +1163,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in AblyTests.queue.async { @@ -1187,7 +1187,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in @@ -1207,7 +1207,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // We want to make sure that the ENTER presence action that we publish // gets sent by Realtime as a PRESENCE protocol message, and not in the // channel’s initial post-attach SYNC. So, we wait for any initial SYNC @@ -1238,7 +1238,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.subscribe(.enter) { member in @@ -1267,7 +1267,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.internal.presenceMap.members.count, 0) waitUntil(timeout: testTimeout) { done in @@ -1289,7 +1289,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.update("online") { error in @@ -1306,7 +1306,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let protocolError = AblyTests.newErrorProtocolMessage() @@ -1330,7 +1330,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter("online") { error in @@ -1362,7 +1362,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.subscribe(.enter) { member in @@ -1392,7 +1392,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.subscribe(.enter) { member in @@ -1418,7 +1418,7 @@ class RealtimeClientPresenceTests: XCTestCase { var clientSecondary: ARTRealtime! defer { clientSecondary.dispose(); clientSecondary.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() clientSecondary = AblyTests.addMembersSequentiallyToChannel(channelName, members: 100, options: options) let client = AblyTests.newRealtime(options).client @@ -1454,7 +1454,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -1508,7 +1508,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let now = NSDate() - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 101, options: options) @@ -1588,7 +1588,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let now = NSDate() - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 101, options: options) @@ -1670,7 +1670,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let timeBeforeSync = NSDate() - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 120, options: options) @@ -1724,7 +1724,7 @@ class RealtimeClientPresenceTests: XCTestCase { func skipped__test__055__Presence__PresenceMap__all_presence_messages_from_a_SYNC_must_also_be_compared_for_newness_in_the_same_way_as_they_would_from_a_PRESENCE__accept_members_where_message_have_arrived_after_the_SYNC() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 120, options: options) @@ -1779,7 +1779,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -1804,7 +1804,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -1831,7 +1831,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__048__Presence__PresenceMap__if_action_of_PRESENT_arrives__it_should_be_added_to_the_presence_map_with_the_action_set_to_PRESENT() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime! defer { clientMembers.dispose(); clientMembers.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 1, options: options) @@ -1862,7 +1862,7 @@ class RealtimeClientPresenceTests: XCTestCase { var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 20, options: options) let client = AblyTests.newRealtime(options).client @@ -1905,7 +1905,7 @@ class RealtimeClientPresenceTests: XCTestCase { func skipped__test__050__Presence__PresenceMap__if_a_SYNC_is_in_progress__then_when_a_presence_message_with_an_action_of_LEAVE_arrives__it_should_be_stored_in_the_presence_map_with_the_action_set_to_ABSENT() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } @@ -1971,7 +1971,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -2001,7 +2001,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in @@ -2021,7 +2021,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.update(nil) { error in @@ -2038,7 +2038,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.attach() channel.detach() @@ -2059,7 +2059,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) AblyTests.queue.async { channel.internal.onError(AblyTests.newErrorProtocolMessage()) @@ -2081,7 +2081,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.update(nil) { error in @@ -2099,7 +2099,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.update(nil) { error in @@ -2118,7 +2118,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter("online") { error in @@ -2142,7 +2142,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter("online") { error in @@ -2168,7 +2168,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.leave("offline") { error in XCTAssertEqual(error?.code, Int(ARTErrorCode.invalidClientId.rawValue)) @@ -2184,7 +2184,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter("online") { error in @@ -2216,7 +2216,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -2250,7 +2250,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) waitUntil(timeout: testTimeout) { done in @@ -2271,7 +2271,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) AblyTests.queue.async { channel.internal.onError(AblyTests.newErrorProtocolMessage()) @@ -2294,7 +2294,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) @@ -2324,7 +2324,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.leave(nil) { error in @@ -2341,7 +2341,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in @@ -2367,7 +2367,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in @@ -2396,7 +2396,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.leaveClient("other", data: nil) { error in @@ -2411,7 +2411,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.leave(nil) { error in @@ -2428,7 +2428,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) channel.presence.subscribe { _ in } @@ -2448,7 +2448,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let protocolError = AblyTests.newErrorProtocolMessage() AblyTests.queue.async { @@ -2471,7 +2471,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let error = AblyTests.newErrorProtocolMessage() @@ -2499,7 +2499,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = AblyTests.newRealtime(options).client defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) // We want to make sure that the ENTER presence action that we publish // gets sent by Realtime as a PRESENCE protocol message, and not in the @@ -2536,7 +2536,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client1 = ARTRealtime(options: options) defer { client1.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) options.clientId = "mary" @@ -2575,7 +2575,7 @@ class RealtimeClientPresenceTests: XCTestCase { func skipped__test__080__Presence__private_and_internal_PresenceMap_containing_only_members_that_match_the_current_connectionId__any_ENTER__PRESENT__UPDATE_or_LEAVE_event_that_matches_the_current_connectionId_should_be_applied_to_this_object() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() options.clientId = "a" let clientA = ARTRealtime(options: options) @@ -2707,7 +2707,7 @@ class RealtimeClientPresenceTests: XCTestCase { func skipped__test__081__Presence__private_and_internal_PresenceMap_containing_only_members_that_match_the_current_connectionId__all_members_belonging_to_the_current_connection_are_published_as_a_PresenceMessage_on_the_Channel_by_the_server_irrespective_of_whether_the_client_has_permission_to_subscribe_or_the_Channel_is_configured_to_publish_presence_events() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let clientId = NSUUID().uuidString options.tokenDetails = try getTestTokenDetails(for: test, clientId: clientId, capability: "{\"\(channelName)\":[\"presence\",\"publish\"]}") // Prevent channel name to be prefixed by test-* @@ -2749,7 +2749,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) channel.presence.subscribe(.enter) { presence in @@ -2849,7 +2849,7 @@ class RealtimeClientPresenceTests: XCTestCase { client.internal.shouldImmediatelyReconnect = false defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) channel.presence.subscribe(.enter) { presence in @@ -2901,7 +2901,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enterClient("Client 1", data: nil) { errorInfo in @@ -2918,7 +2918,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.token = try getTestToken(for: test, capability: "{ \"room\":[\"subscribe\"] }") let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enterClient("Client 1", data: nil) { errorInfo in @@ -2939,7 +2939,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in @@ -2972,7 +2972,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) waitUntil(timeout: testTimeout) { done in @@ -2993,7 +2993,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let expectedErrorMessage = "Something has failed" AblyTests.queue.async { @@ -3021,7 +3021,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let error = AblyTests.newErrorProtocolMessage() @@ -3109,7 +3109,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.clientId = "john" let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enter("browser") { error in @@ -3136,7 +3136,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enterClient("user", data: nil) { error in @@ -3156,7 +3156,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertTrue(client.internal.options.queueMessages) waitUntil(timeout: testTimeout) { done in @@ -3185,7 +3185,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.queueMessages = false let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertFalse(client.internal.options.queueMessages) expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) @@ -3214,7 +3214,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.queueMessages = false let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.initialized) @@ -3230,7 +3230,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__097__Presence__Connection_state_conditions__should_result_in_an_error_if_the_connection_state_is__suspended() throws { let test = Test() - try testResultsInErrorWithConnectionState(.suspended, for: test, channelName: uniqueChannelName(for: test)) { client in + try testResultsInErrorWithConnectionState(.suspended, for: test, channelName: test.uniqueChannelName()) { client in AblyTests.queue.async { client.internal.onSuspended() } @@ -3239,14 +3239,14 @@ class RealtimeClientPresenceTests: XCTestCase { func test__098__Presence__Connection_state_conditions__should_result_in_an_error_if_the_connection_state_is__closed() throws { let test = Test() - try testResultsInErrorWithConnectionState(.closed, for: test, channelName: uniqueChannelName(for: test)) { client in + try testResultsInErrorWithConnectionState(.closed, for: test, channelName: test.uniqueChannelName()) { client in client.close() } } func test__099__Presence__Connection_state_conditions__should_result_in_an_error_if_the_connection_state_is__failed() throws { let test = Test() - try testResultsInErrorWithConnectionState(.failed, for: test, channelName: uniqueChannelName(for: test)) { client in + try testResultsInErrorWithConnectionState(.failed, for: test, channelName: test.uniqueChannelName()) { client in AblyTests.queue.async { client.internal.onError(AblyTests.newErrorProtocolMessage()) } @@ -3275,7 +3275,7 @@ class RealtimeClientPresenceTests: XCTestCase { let expectedData = "online" - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 150, data: expectedData as AnyObject?, options: options)] let client = ARTRealtime(options: options) @@ -3309,7 +3309,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) waitUntil(timeout: testTimeout) { done in @@ -3328,7 +3328,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let pm = AblyTests.newErrorProtocolMessage() AblyTests.queue.async { @@ -3360,7 +3360,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let pm = AblyTests.newErrorProtocolMessage() @@ -3391,7 +3391,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach() @@ -3422,7 +3422,7 @@ class RealtimeClientPresenceTests: XCTestCase { var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 120, options: options) let channel = client.channels.get(channelName) @@ -3449,14 +3449,14 @@ class RealtimeClientPresenceTests: XCTestCase { func test__107__Presence__get__If_the_Channel_is_in_the_SUSPENDED_state_then__by_default__results_in_an_error() throws { let test = Test() - try testSuspendedStateResultsInError(for: test, channelName: uniqueChannelName(for: test)) { channel, callback in + try testSuspendedStateResultsInError(for: test, channelName: test.uniqueChannelName()) { channel, callback in channel.presence.get(callback) } } func test__108__Presence__get__If_the_Channel_is_in_the_SUSPENDED_state_then__if_waitForSync_is_true__results_in_an_error() throws { let test = Test() - try testSuspendedStateResultsInError(for: test, channelName: uniqueChannelName(for: test)) { channel, callback in + try testSuspendedStateResultsInError(for: test, channelName: test.uniqueChannelName()) { channel, callback in let params = ARTRealtimePresenceQuery() params.waitForSync = true channel.presence.get(params, callback: callback) @@ -3465,7 +3465,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__109__Presence__get__If_the_Channel_is_in_the_SUSPENDED_state_then__if_waitForSync_is_false__returns_the_members_in_the_current_PresenceMap() throws { let test = Test() - let (channel, client) = try getSuspendedChannel(named: uniqueChannelName(for: test), for: test) + let (channel, client) = try getSuspendedChannel(named: test.uniqueChannelName(), for: test) defer { client.dispose(); client.close() } var msgs = [String: ARTPresenceMessage]() @@ -3498,7 +3498,7 @@ class RealtimeClientPresenceTests: XCTestCase { var clientSecondary: ARTRealtime! defer { clientSecondary.dispose(); clientSecondary.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() clientSecondary = AblyTests.addMembersSequentiallyToChannel(channelName, members: 150, options: options) let client = AblyTests.newRealtime(options).client @@ -3538,7 +3538,7 @@ class RealtimeClientPresenceTests: XCTestCase { var clientSecondary: ARTRealtime! defer { clientSecondary.dispose(); clientSecondary.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() clientSecondary = AblyTests.addMembersSequentiallyToChannel(channelName, members: 150, options: options) let client = AblyTests.newRealtime(options).client @@ -3592,7 +3592,7 @@ class RealtimeClientPresenceTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) let presenceData: [ARTPresenceMessage] = [ @@ -3649,7 +3649,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let now = NSDate() - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var clientMembers: ARTRealtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 101, options: options) @@ -3737,7 +3737,7 @@ class RealtimeClientPresenceTests: XCTestCase { let realtime = ARTRealtime(options: options) defer { realtime.dispose(); realtime.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channelRest = rest.channels.get(channelName) let channelRealtime = realtime.channels.get(channelName) @@ -3794,7 +3794,7 @@ class RealtimeClientPresenceTests: XCTestCase { let expectedData = ["x", "y"] let expectedPattern = "^user(\\d+)$" - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() clientSecondary = AblyTests.addMembersSequentiallyToChannel(channelName, members: 150, data: expectedData as AnyObject?, options: options) let client = ARTRealtime(options: options) @@ -3854,7 +3854,7 @@ class RealtimeClientPresenceTests: XCTestCase { } } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 250, options: options)] let client = AblyTests.newRealtime(options).client @@ -3883,7 +3883,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.internal.presenceMap.members.count, 0) let expectedData = ["test": 1] @@ -3933,7 +3933,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) let john = "john" diff --git a/Test/Tests/RealtimeClientTests.swift b/Test/Tests/RealtimeClientTests.swift index b5c3558a4..9a2af6076 100644 --- a/Test/Tests/RealtimeClientTests.swift +++ b/Test/Tests/RealtimeClientTests.swift @@ -42,7 +42,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let client = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in XCTAssertNil(error) @@ -254,7 +254,7 @@ class RealtimeClientTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() client.channels.get(channelName).subscribe { _ in // Attached @@ -564,7 +564,7 @@ class RealtimeClientTests: XCTestCase { client.connect() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.once(.failed) { stateChange in guard let error = stateChange.reason else { @@ -648,7 +648,7 @@ class RealtimeClientTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connect() channel.attach { error in @@ -1293,7 +1293,7 @@ class RealtimeClientTests: XCTestCase { return } - realtime.channels.get(uniqueChannelName(for: test)).attach { error in + realtime.channels.get(test.uniqueChannelName()).attach { error in XCTAssertNil(error) realtime.close() done() @@ -1306,7 +1306,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let realtime = AblyTests.newRealtime(try AblyTests.commonAppSetup(for: test)).client defer { realtime.dispose(); realtime.close() } - let channel = realtime.channels.get(uniqueChannelName(for: test)) + let channel = realtime.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -1401,7 +1401,7 @@ class RealtimeClientTests: XCTestCase { realtime2.dispose(); realtime2.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let subscribeChannel = realtime1.channels.get(channelName) let sendChannel = realtime2.channels.get(channelName) @@ -1433,7 +1433,7 @@ class RealtimeClientTests: XCTestCase { // Issue https://github.com/ably/ably-cocoa/issues/640 func test__009__RealtimeClient__should_dispatch_in_user_queue_when_removing_an_observer() { let test = Test() - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() class Foo { private let channelName: String init(channelName: String) { @@ -1482,7 +1482,7 @@ class RealtimeClientTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { _ in done() @@ -1518,7 +1518,7 @@ class RealtimeClientTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() var received = false client.channels.get(channelName).subscribe { _ in @@ -1544,7 +1544,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let messages = buildMessagesThatExceedMaxMessageSize() defer { client.dispose(); client.close() } @@ -1564,7 +1564,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout, action: { done in @@ -1582,7 +1582,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout, action: { done in @@ -1600,7 +1600,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout, action: { done in @@ -1618,7 +1618,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout, action: { done in @@ -1636,7 +1636,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId let client = ARTRealtime(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout, action: { done in diff --git a/Test/Tests/RestClientChannelTests.swift b/Test/Tests/RestClientChannelTests.swift index 96254b737..24154c2bb 100644 --- a/Test/Tests/RestClientChannelTests.swift +++ b/Test/Tests/RestClientChannelTests.swift @@ -151,7 +151,7 @@ class RestClientChannelTests: XCTestCase { var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) var publishedMessage: ARTMessage? - let channel = testEnvironment.client.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) channel.publish(PublishArgs.name, data: PublishArgs.data) { error in publishError = error @@ -174,7 +174,7 @@ class RestClientChannelTests: XCTestCase { var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "io.ably.XCTest", code: -1, userInfo: nil)) var publishedMessage: ARTMessage? - let channel = testEnvironment.client.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) channel.publish(PublishArgs.name, data: nil) { error in publishError = error @@ -197,7 +197,7 @@ class RestClientChannelTests: XCTestCase { var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) var publishedMessage: ARTMessage? - let channel = testEnvironment.client.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) channel.publish(nil, data: PublishArgs.data) { error in publishError = error @@ -220,7 +220,7 @@ class RestClientChannelTests: XCTestCase { var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) var publishedMessage: ARTMessage? - let channel = testEnvironment.client.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: nil) { error in @@ -244,7 +244,7 @@ class RestClientChannelTests: XCTestCase { var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) var publishedMessage: ARTMessage? - let channel = testEnvironment.client.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([ARTMessage(name: PublishArgs.name, data: PublishArgs.data)]) { error in @@ -281,7 +281,7 @@ class RestClientChannelTests: XCTestCase { ARTMessage(name: "bat", data: "baz"), ] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.publish(messages) { error in publishError = error @@ -308,7 +308,7 @@ class RestClientChannelTests: XCTestCase { func test__011__publish__Unidentified_clients_using_Basic_Auth__should_publish_message_with_the_provided_clientId() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([ARTMessage(name: nil, data: "message", clientId: "tester")]) { error in XCTAssertNil(error) @@ -338,7 +338,7 @@ class RestClientChannelTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test, prefix: "RSA7e1")) + client.channels.get(test.uniqueChannelName(prefix: "RSA7e1")) .publish(nil, data: "foo") { error in XCTAssertNil(error) guard let connection = client.internal.transport as? TestProxyTransport else { @@ -360,7 +360,7 @@ class RestClientChannelTests: XCTestCase { let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test, prefix: "RSA7e1")) + client.channels.get(test.uniqueChannelName(prefix: "RSA7e1")) .publish(nil, data: "foo") { error in XCTAssertNil(error) guard let request = testHTTPExecutor.requests.first else { @@ -388,7 +388,7 @@ class RestClientChannelTests: XCTestCase { options.clientId = "client-realtime" let realtime = ARTRealtime(options: options) - let chanelName = uniqueChannelName(for: test, prefix: "ch1") + let chanelName = test.uniqueChannelName(prefix: "ch1") let subscriber = realtime.channels.get(chanelName) waitUntil(timeout: testTimeout) { done in @@ -420,7 +420,7 @@ class RestClientChannelTests: XCTestCase { options.clientId = "client-realtime" let realtime = ARTRealtime(options: options) - let chanelName = uniqueChannelName(for: test, prefix: "ch1") + let chanelName = test.uniqueChannelName(prefix: "ch1") let subscriber = realtime.channels.get(chanelName) waitUntil(timeout: testTimeout) { done in @@ -450,7 +450,7 @@ class RestClientChannelTests: XCTestCase { let rest = ARTRest(options: options) let realtime = ARTRealtime(options: options) - let chanelName = uniqueChannelName(for: test, prefix: "ch1") + let chanelName = test.uniqueChannelName(prefix: "ch1") let subscriber = realtime.channels.get(chanelName) waitUntil(timeout: testTimeout) { done in @@ -481,7 +481,7 @@ class RestClientChannelTests: XCTestCase { options.clientId = "client-realtime" let realtime = ARTRealtime(options: options) - let chanelName = uniqueChannelName(for: test, prefix: "ch1") + let chanelName = test.uniqueChannelName(prefix: "ch1") let subscriber = realtime.channels.get(chanelName) waitUntil(timeout: testTimeout) { done in @@ -518,7 +518,7 @@ class RestClientChannelTests: XCTestCase { } let rest = ARTRest(options: options) - let channel = rest.channels.get(uniqueChannelName(for: test, prefix: "issue-1074")) + let channel = rest.channels.get(test.uniqueChannelName(prefix: "issue-1074")) waitUntil(timeout: testTimeout) { done in // The first attempt encodes the message before requesting auth credentials so there's no clientId @@ -542,7 +542,7 @@ class RestClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("name", data: "some data", clientId: "tester") { error in expect(error!.message).to(contain("invalid clientId")) @@ -558,7 +558,7 @@ class RestClientChannelTests: XCTestCase { // Prevent channel name to be prefixed by test-* options.testOptions.channelNamePrefix = nil let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test, prefix: "pushenabled:test")) + let channel = client.channels.get(test.uniqueChannelName(prefix: "pushenabled:test")) let extras = ["push": ["notification": ["title": "Hello from Ably!"]]] as ARTJsonCompatible XCTAssertTrue((client.internal.encoders["application/json"] as! ARTJsonLikeEncoder).message(from: [ @@ -598,7 +598,7 @@ class RestClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let messages = buildMessagesThatExceedMaxMessageSize() waitUntil(timeout: testTimeout) { done in @@ -613,7 +613,7 @@ class RestClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let name = buildStringThatExceedMaxMessageSize() waitUntil(timeout: testTimeout) { done in @@ -657,7 +657,7 @@ class RestClientChannelTests: XCTestCase { rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([message]) { error in @@ -688,7 +688,7 @@ class RestClientChannelTests: XCTestCase { rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([message1, message2]) { error in @@ -721,7 +721,7 @@ class RestClientChannelTests: XCTestCase { rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([message]) { error in @@ -746,7 +746,7 @@ class RestClientChannelTests: XCTestCase { rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("john", data: "foo") { error in @@ -776,7 +776,7 @@ class RestClientChannelTests: XCTestCase { rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([message1, message2]) { error in @@ -807,7 +807,7 @@ class RestClientChannelTests: XCTestCase { let rest = ARTRest(options: options) let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([message1, message2]) { error in @@ -853,7 +853,7 @@ class RestClientChannelTests: XCTestCase { ARTMessage(name: nil, data: "test3"), ] - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(messages) { error in @@ -882,7 +882,7 @@ class RestClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let rest = ARTRest(options: options) rest.internal.options.idempotentRestPublishing = true - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) let message = ARTMessage(name: "unique", data: "foo") message.id = "123" @@ -917,7 +917,7 @@ class RestClientChannelTests: XCTestCase { let proxyHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = proxyHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let message = ARTMessage(name: nil, data: "") message.id = "123" message.name = "tester" @@ -950,7 +950,7 @@ class RestClientChannelTests: XCTestCase { func test__029__history__should_return_a_PaginatedResult_page_containing_the_first_page_of_messages() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish([ @@ -1028,7 +1028,7 @@ class RestClientChannelTests: XCTestCase { func test__030__history__query_arguments__start_and_end_should_filter_messages_between_those_two_times() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTDataQuery() XCTAssertEqual(query.direction, ARTQueryDirection.backwards) @@ -1088,7 +1088,7 @@ class RestClientChannelTests: XCTestCase { func test__031__history__query_arguments__start_must_be_equal_to_or_less_than_end_and_is_unaffected_by_the_request_direction() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTDataQuery() query.direction = .backwards @@ -1110,7 +1110,7 @@ class RestClientChannelTests: XCTestCase { func test__032__history__query_arguments__direction_backwards_or_forwards() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTDataQuery() XCTAssertEqual(query.direction, ARTQueryDirection.backwards) @@ -1152,7 +1152,7 @@ class RestClientChannelTests: XCTestCase { func test__033__history__query_arguments__limit_items_result() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTDataQuery() XCTAssertEqual(query.limit, 100) @@ -1191,7 +1191,7 @@ class RestClientChannelTests: XCTestCase { func test__034__history__query_arguments__limit_supports_up_to_1000_items() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTDataQuery() XCTAssertEqual(query.limit, 100) @@ -1268,7 +1268,7 @@ class RestClientChannelTests: XCTestCase { client.internal.options.idempotentRestPublishing = false client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) validCases.forEach { caseTest in waitUntil(timeout: testTimeout) { done in @@ -1324,7 +1324,7 @@ class RestClientChannelTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) encodingCases.forEach { caseItem in waitUntil(timeout: testTimeout) { done in @@ -1358,7 +1358,7 @@ class RestClientChannelTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: binaryData, callback: { error in @@ -1385,7 +1385,7 @@ class RestClientChannelTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: text, callback: { error in @@ -1414,7 +1414,7 @@ class RestClientChannelTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // JSON Array waitUntil(timeout: testTimeout) { done in @@ -1445,7 +1445,7 @@ class RestClientChannelTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) // JSON Object waitUntil(timeout: testTimeout) { done in @@ -1475,7 +1475,7 @@ class RestClientChannelTests: XCTestCase { let cases = [text, integer, decimal, dictionary, array, binaryData] as [Any] - let channel = testEnvironment.client.channels.get(uniqueChannelName(for: test)) + let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) cases.forEach { caseTest in waitUntil(timeout: testTimeout) { done in @@ -1522,13 +1522,13 @@ class RestClientChannelTests: XCTestCase { func test__043__message_payload_encryption__should_support_AES_encryption__128_CBC_mode() throws { let test = Test() let testEnvironment = try TestEnvironment(test: test) - try testSupportsAESEncryptionWithKeyLength(128, for: test, channelName: uniqueChannelName(for: test), testHTTPExecutor: testEnvironment.testHTTPExecutor) + try testSupportsAESEncryptionWithKeyLength(128, for: test, channelName: test.uniqueChannelName(), testHTTPExecutor: testEnvironment.testHTTPExecutor) } func test__044__message_payload_encryption__should_support_AES_encryption__256_CBC_mode() throws { let test = Test() let testEnvironment = try TestEnvironment(test: test) - try testSupportsAESEncryptionWithKeyLength(256, for: test, channelName: uniqueChannelName(for: test), testHTTPExecutor: testEnvironment.testHTTPExecutor) + try testSupportsAESEncryptionWithKeyLength(256, for: test, channelName: test.uniqueChannelName(), testHTTPExecutor: testEnvironment.testHTTPExecutor) } // RSL6 @@ -1539,7 +1539,7 @@ class RestClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let clientEncrypted = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channelOptions = ARTChannelOptions(cipher: ["key": ARTCrypto.generateRandomKey()] as ARTCipherParamsCompatible) let channelEncrypted = clientEncrypted.channels.get(channelName, options: channelOptions) @@ -1581,7 +1581,7 @@ class RestClientChannelTests: XCTestCase { options.logHandler = ARTLog(capturingOutput: true) let client = ARTRest(options: options) let channelOptions = ARTChannelOptions(cipher: ["key": ARTCrypto.generateRandomKey()] as ARTCipherParamsCompatible) - let channel = client.channels.get(uniqueChannelName(for: test), options: channelOptions) + let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) client.internal.httpExecutor = testHTTPExecutor let expectedMessage = ["something": 1] @@ -1625,7 +1625,7 @@ class RestClientChannelTests: XCTestCase { options.clientId = "Client 1" let rest = ARTRest(options: options) let realtime = ARTRealtime(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let realtimeChannel = realtime.channels.get(channelName) let restChannel = rest.channels.get(channelName) @@ -1660,7 +1660,7 @@ class RestClientChannelTests: XCTestCase { let testHTTPExecutor = testEnvironment.testHTTPExecutor client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test, prefix: "beforeSlash/afterSlash")) + let channel = client.channels.get(test.uniqueChannelName(prefix: "beforeSlash/afterSlash")) channel.publish(nil, data: nil) diff --git a/Test/Tests/RestClientPresenceTests.swift b/Test/Tests/RestClientPresenceTests.swift index 743392a5b..9cecc05bb 100644 --- a/Test/Tests/RestClientPresenceTests.swift +++ b/Test/Tests/RestClientPresenceTests.swift @@ -10,7 +10,7 @@ class RestClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) var disposable = [ARTRealtime]() @@ -68,7 +68,7 @@ class RestClientPresenceTests: XCTestCase { func test__003__Presence__get__limit_should_support_up_to_1000_items() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTPresenceQuery() XCTAssertEqual(query.limit, 100) @@ -84,7 +84,7 @@ class RestClientPresenceTests: XCTestCase { func test__004__Presence__get__clientId_should_filter_members_by_the_provided_clientId() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let client = ARTRest(options: options) let channel = client.channels.get(channelName) @@ -122,7 +122,7 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) var disposable = [ARTRealtime]() @@ -168,7 +168,7 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) var realtime: ARTRealtime! @@ -230,7 +230,7 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) var disposable = [ARTRealtime]() @@ -285,7 +285,7 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) var realtime: ARTRealtime! @@ -321,7 +321,7 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) var disposable = [ARTRealtime]() @@ -369,7 +369,7 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) var disposable = [ARTRealtime]() @@ -423,7 +423,7 @@ class RestClientPresenceTests: XCTestCase { func test__011__Presence__history__query_argument__start_must_be_equal_to_or_less_than_end_and_is_unaffected_by_the_request_direction() throws { let test = Test() let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) let query = ARTDataQuery() query.direction = .backwards @@ -447,7 +447,7 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) let expectedData = ["test": 1] diff --git a/Test/Tests/RestClientTests.swift b/Test/Tests/RestClientTests.swift index ae47457a3..081a8dd4d 100644 --- a/Test/Tests/RestClientTests.swift +++ b/Test/Tests/RestClientTests.swift @@ -154,7 +154,7 @@ class RestClientTests: XCTestCase { let client = ARTRest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in XCTAssertNil(error) @@ -178,7 +178,7 @@ class RestClientTests: XCTestCase { let client = ARTRest(key: options.key!) client.internal.prioritizedHost = options.restHost - let publishTask = publishTestMessage(client, channelName: uniqueChannelName(for: test)) + let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) expect(publishTask.error).toEventually(beNil(), timeout: testTimeout) } @@ -191,7 +191,7 @@ class RestClientTests: XCTestCase { let test = Test() let client = ARTRest(key: "fake:key") - let publishTask = publishTestMessage(client, channelName: uniqueChannelName(for: test), failOnError: false) + let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) expect(publishTask.error?.code).toEventually(equal(ARTErrorCode.invalidCredential.intValue), timeout: testTimeout) } @@ -202,7 +202,7 @@ class RestClientTests: XCTestCase { defer { ARTClientOptions.setDefaultEnvironment(nil) } let client = ARTRest(token: try getTestToken(for: test)) - let publishTask = publishTestMessage(client, channelName: uniqueChannelName(for: test)) + let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) expect(publishTask.error).toEventually(beNil(), timeout: testTimeout) } @@ -211,7 +211,7 @@ class RestClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = ARTRest(options: options) - let publishTask = publishTestMessage(client, channelName: uniqueChannelName(for: test)) + let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) expect(publishTask.error).toEventually(beNil(), timeout: testTimeout) } @@ -221,7 +221,7 @@ class RestClientTests: XCTestCase { let options = try AblyTests.clientOptions(for: test, requestToken: true) let client = ARTRest(options: options) - let publishTask = publishTestMessage(client, channelName: uniqueChannelName(for: test)) + let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) expect(publishTask.error).toEventually(beNil(), timeout: testTimeout) } @@ -232,7 +232,7 @@ class RestClientTests: XCTestCase { options.token = "invalid_token" let client = ARTRest(options: options) - let publishTask = publishTestMessage(client, channelName: uniqueChannelName(for: test), failOnError: false) + let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) expect(publishTask.error?.code).toEventually(equal(ARTErrorCode.invalidCredential.intValue), timeout: testTimeout) } @@ -312,7 +312,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor - publishTestMessage(client, channelName: uniqueChannelName(for: test), failOnError: false) + publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) expect(testHTTPExecutor.requests.first?.url?.host).toEventually(equal("fake.ably.io"), timeout: testTimeout) } @@ -326,7 +326,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor - publishTestMessage(client, channelName: uniqueChannelName(for: test), failOnError: false) + publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) expect(testHTTPExecutor.requests.first?.url?.host).toEventually(equal("fake.ably.io"), timeout: testTimeout) } @@ -340,7 +340,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor - publishTestMessage(client, channelName: uniqueChannelName(for: test), failOnError: false) + publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) expect(testHTTPExecutor.requests.first?.url?.host).toEventually(equal("myEnvironment-rest.ably.io"), timeout: testTimeout) } @@ -352,7 +352,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor - publishTestMessage(client, channelName: uniqueChannelName(for: test), failOnError: false) + publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) expect(testHTTPExecutor.requests.first?.url?.absoluteString).toEventually(beginWith("https://rest.ably.io"), timeout: testTimeout) } @@ -365,7 +365,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor - publishTestMessage(client, channelName: uniqueChannelName(for: test), failOnError: false) + publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) expect(testHTTPExecutor.requests.first?.url?.scheme).toEventually(equal("http"), timeout: testTimeout) } @@ -388,7 +388,7 @@ class RestClientTests: XCTestCase { XCTAssertEqual(options.httpRequestTimeout, 10.0) // Seconds options.httpRequestTimeout = 1.0 let client = ARTRest(options: options) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let start = NSDate() channel.publish(nil, data: "message") { error in @@ -422,7 +422,7 @@ class RestClientTests: XCTestCase { } } - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in done() @@ -442,7 +442,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .requestTimeout(timeout: 0.1)) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let start = Date() channel.publish(nil, data: "nil") { _ in @@ -475,7 +475,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { error in + client.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { error in XCTAssertNotNil(error) done() } @@ -511,7 +511,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) clientHttps.internal.httpExecutor = testHTTPExecutor - let channelName = uniqueChannelName(for: test) + let channelName = test.uniqueChannelName() waitUntil(timeout: testTimeout) { done in publishTestMessage(clientHttps, channelName: channelName) { _ in @@ -583,7 +583,7 @@ class RestClientTests: XCTestCase { waitUntil(timeout: testTimeout) { done in delay(1.0) { - client.channels.get(uniqueChannelName(for: test)).history { result, error in + client.channels.get(test.uniqueChannelName()).history { result, error in XCTAssertNil(error) XCTAssertNotNil(result) @@ -611,7 +611,7 @@ class RestClientTests: XCTestCase { client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test)).history { result, error in + client.channels.get(test.uniqueChannelName()).history { result, error in guard let errorCode = error?.code else { fail("Error is empty"); done() return @@ -644,7 +644,7 @@ class RestClientTests: XCTestCase { } let rest = ARTRest(key: "\(keyName):\(keySecret)") waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test)).publish(nil, data: "testing") { error in + rest.channels.get(test.uniqueChannelName()).publish(nil, data: "testing") { error in XCTAssertNil(error) done() } @@ -737,7 +737,7 @@ class RestClientTests: XCTestCase { // Delay for token expiration delay(TimeInterval(truncating: tokenParams.ttl!)) { // [40140, 40150) - token expired and will not recover because authUrl is invalid - publishTestMessage(rest, channelName: uniqueChannelName(for: test)) { error in + publishTestMessage(rest, channelName: test.uniqueChannelName()) { error in guard let errorCode = testHTTPExecutor.responses.first?.value(forHTTPHeaderField: "X-Ably-Errorcode") else { fail("expected X-Ably-Errorcode header in response") return @@ -800,7 +800,7 @@ class RestClientTests: XCTestCase { // Delay for token expiration delay(TimeInterval(truncating: tokenParams.ttl!)) { // [40140, 40150) - token expired and will not recover because authUrl is invalid - publishTestMessage(rest, channelName: uniqueChannelName(for: test)) { error in + publishTestMessage(rest, channelName: test.uniqueChannelName()) { error in guard let errorCode = testHTTPExecutor.responses.first?.value(forHTTPHeaderField: "X-Ably-Errorcode") else { fail("expected X-Ably-Errorcode header in response") return @@ -898,7 +898,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable, resetAfter: 2) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -926,7 +926,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -953,7 +953,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -979,7 +979,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -1005,7 +1005,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -1033,7 +1033,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable, resetAfter: 2) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -1060,7 +1060,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in expect(error?.message).to(contain("hostname could not be found")) @@ -1083,7 +1083,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -1109,7 +1109,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable, resetAfter: 2) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -1136,7 +1136,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -1164,7 +1164,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "") { error in @@ -1194,7 +1194,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable, resetAfter: 1) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { error in @@ -1219,7 +1219,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1243,7 +1243,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable, resetAfter: 1) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1272,7 +1272,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable, resetAfter: 1) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1326,7 +1326,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1362,7 +1362,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1392,7 +1392,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1424,7 +1424,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1457,7 +1457,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1489,7 +1489,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1522,7 +1522,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .hostUnreachable) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1538,17 +1538,17 @@ class RestClientTests: XCTestCase { func test__074__RestClient__Host_Fallback__should_use_an_alternative_host_when___hostUnreachable() { let test = Test() - testUsesAlternativeHost(.hostUnreachable, channelName: uniqueChannelName(for: test)) + testUsesAlternativeHost(.hostUnreachable, channelName: test.uniqueChannelName()) } func test__075__RestClient__Host_Fallback__should_use_an_alternative_host_when___requestTimeout_timeout__0_1_() { let test = Test() - testUsesAlternativeHost(.requestTimeout(timeout: 0.1), channelName: uniqueChannelName(for: test)) + testUsesAlternativeHost(.requestTimeout(timeout: 0.1), channelName: test.uniqueChannelName()) } func test__076__RestClient__Host_Fallback__should_use_an_alternative_host_when___hostInternalError_code__501_() { let test = Test() - testUsesAlternativeHost(.hostInternalError(code: 501), channelName: uniqueChannelName(for: test)) + testUsesAlternativeHost(.hostInternalError(code: 501), channelName: test.uniqueChannelName()) } // RSC15d @@ -1561,7 +1561,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) client.internal.httpExecutor = testHTTPExecutor mockHTTP.setNetworkState(network: .host400BadRequest, resetAfter: 1) - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "nil") { _ in @@ -1577,47 +1577,47 @@ class RestClientTests: XCTestCase { func test__077__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host___hostUnreachable() { let test = Test() - testStoresSuccessfulFallbackHostAsDefaultHost(.hostUnreachable, channelName: uniqueChannelName(for: test)) + testStoresSuccessfulFallbackHostAsDefaultHost(.hostUnreachable, channelName: test.uniqueChannelName()) } func test__078__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host___requestTimeout_timeout__0_1_() { let test = Test() - testStoresSuccessfulFallbackHostAsDefaultHost(.requestTimeout(timeout: 0.1), channelName: uniqueChannelName(for: test)) + testStoresSuccessfulFallbackHostAsDefaultHost(.requestTimeout(timeout: 0.1), channelName: test.uniqueChannelName()) } func test__079__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host___hostInternalError_code__501_() { let test = Test() - testStoresSuccessfulFallbackHostAsDefaultHost(.hostInternalError(code: 501), channelName: uniqueChannelName(for: test)) + testStoresSuccessfulFallbackHostAsDefaultHost(.hostInternalError(code: 501), channelName: test.uniqueChannelName()) } func test__080__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host__should_restore_default_primary_host_after_fallbackRetryTimeout_expired___hostUnreachable() { let test = Test() - testRestoresDefaultPrimaryHostAfterTimeoutExpires(.hostUnreachable, channelName: uniqueChannelName(for: test)) + testRestoresDefaultPrimaryHostAfterTimeoutExpires(.hostUnreachable, channelName: test.uniqueChannelName()) } func test__081__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host__should_restore_default_primary_host_after_fallbackRetryTimeout_expired___requestTimeout_timeout__0_1_() { let test = Test() - testRestoresDefaultPrimaryHostAfterTimeoutExpires(.requestTimeout(timeout: 0.1), channelName: uniqueChannelName(for: test)) + testRestoresDefaultPrimaryHostAfterTimeoutExpires(.requestTimeout(timeout: 0.1), channelName: test.uniqueChannelName()) } func test__082__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host__should_restore_default_primary_host_after_fallbackRetryTimeout_expired___hostInternalError_code__501_() { let test = Test() - testRestoresDefaultPrimaryHostAfterTimeoutExpires(.hostInternalError(code: 501), channelName: uniqueChannelName(for: test)) + testRestoresDefaultPrimaryHostAfterTimeoutExpires(.hostInternalError(code: 501), channelName: test.uniqueChannelName()) } func test__083__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host__should_use_another_fallback_host_if_previous_fallback_request_failed_and_store_it_as_default_if_current_fallback_request_succseeded___hostUnreachable() { let test = Test() - testUsesAnotherFallbackHost(.hostUnreachable, channelName: uniqueChannelName(for: test)) + testUsesAnotherFallbackHost(.hostUnreachable, channelName: test.uniqueChannelName()) } func test__084__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host__should_use_another_fallback_host_if_previous_fallback_request_failed_and_store_it_as_default_if_current_fallback_request_succseeded___requestTimeout_timeout__0_1_() { let test = Test() - testUsesAnotherFallbackHost(.requestTimeout(timeout: 0.1), channelName: uniqueChannelName(for: test)) + testUsesAnotherFallbackHost(.requestTimeout(timeout: 0.1), channelName: test.uniqueChannelName()) } func test__085__RestClient__Host_Fallback__should_store_successful_fallback_host_as_default_host__should_use_another_fallback_host_if_previous_fallback_request_failed_and_store_it_as_default_if_current_fallback_request_succseeded___hostInternalError_code__501_() { let test = Test() - testUsesAnotherFallbackHost(.hostInternalError(code: 501), channelName: uniqueChannelName(for: test)) + testUsesAnotherFallbackHost(.hostInternalError(code: 501), channelName: test.uniqueChannelName()) } // RSC8a @@ -1630,7 +1630,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test, prefix: "rest")).publish(nil, data: "message") { _ in + rest.channels.get(test.uniqueChannelName(prefix: "rest")).publish(nil, data: "message") { _ in done() } } @@ -1646,7 +1646,7 @@ class RestClientTests: XCTestCase { let realtime = AblyTests.newRealtime(options).client defer { realtime.close() } waitUntil(timeout: testTimeout) { done in - realtime.channels.get(uniqueChannelName(for: test, prefix: "realtime")).publish(nil, data: "message") { _ in + realtime.channels.get(test.uniqueChannelName(prefix: "realtime")).publish(nil, data: "message") { _ in done() } } @@ -1668,7 +1668,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test, prefix: "rest")).publish(nil, data: "message") { _ in + rest.channels.get(test.uniqueChannelName(prefix: "rest")).publish(nil, data: "message") { _ in done() } } @@ -1684,7 +1684,7 @@ class RestClientTests: XCTestCase { let realtime = AblyTests.newRealtime(options).client defer { realtime.close() } waitUntil(timeout: testTimeout) { done in - realtime.channels.get(uniqueChannelName(for: test, prefix: "realtime")).publish(nil, data: "message") { _ in + realtime.channels.get(test.uniqueChannelName(prefix: "realtime")).publish(nil, data: "message") { _ in done() } } @@ -1702,7 +1702,7 @@ class RestClientTests: XCTestCase { testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in - client.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { error in + client.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { error in XCTAssertNil(error) guard let headerAblyVersion = testHTTPExecutor.requests.first?.allHTTPHeaderFields?["X-Ably-Version"] else { fail("X-Ably-Version header not found"); done() @@ -1727,7 +1727,7 @@ class RestClientTests: XCTestCase { let client = ARTRest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in XCTAssertNil(error) @@ -1748,7 +1748,7 @@ class RestClientTests: XCTestCase { let client = ARTRest(options: options) waitUntil(timeout: testTimeout) { done in delay(0.1) { - client.channels.get(uniqueChannelName(for: test)).publish(nil, data: "message") { error in + client.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { error in guard let error = error else { fail("Error is empty"); done() return @@ -1768,7 +1768,7 @@ class RestClientTests: XCTestCase { waitUntil(timeout: testTimeout) { done in URLSession.shared.dataTask(with: URL(string: "https://ably.io")!) { _, _, _ in let rest = ARTRest(options: options) - rest.channels.get(uniqueChannelName(for: test)).history { _, _ in + rest.channels.get(test.uniqueChannelName()).history { _, _ in done() } }.resume() @@ -1946,7 +1946,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let rest = ARTRest(options: options) - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("a", data: nil) { error in XCTAssertNil(error) @@ -1996,7 +1996,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let rest = ARTRest(options: options) - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("a", data: nil) { error in XCTAssertNil(error) @@ -2050,7 +2050,7 @@ class RestClientTests: XCTestCase { let client = ARTRest(options: options) waitUntil(timeout: testTimeout) { done in - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) channel.publish("test", data: "test-data") { error in guard let error = error else { fail("Error should not be empty") @@ -2076,7 +2076,7 @@ class RestClientTests: XCTestCase { let mockHttpExecutor = MockHTTPExecutor() restA.internal.httpExecutor = mockHttpExecutor waitUntil(timeout: testTimeout) { done in - restA.channels.get(uniqueChannelName(for: test)).publish(nil, data: "something") { error in + restA.channels.get(test.uniqueChannelName()).publish(nil, data: "something") { error in XCTAssertNil(error) guard let url = mockHttpExecutor.requests.first?.url else { fail("No requests found") @@ -2093,7 +2093,7 @@ class RestClientTests: XCTestCase { let restB = ARTRest(options: options) restB.internal.httpExecutor = mockHttpExecutor waitUntil(timeout: testTimeout) { done in - restB.channels.get(uniqueChannelName(for: test)).publish(nil, data: "something") { error in + restB.channels.get(test.uniqueChannelName()).publish(nil, data: "something") { error in XCTAssertNil(error) XCTAssertEqual(mockHttpExecutor.requests.count, 1) guard let url = mockHttpExecutor.requests.first?.url else { @@ -2128,7 +2128,7 @@ class RestClientTests: XCTestCase { } var requestId: String = "" - let channel = client.channels.get(uniqueChannelName(for: test)) + let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "something") { error in guard let error = error else { @@ -2158,7 +2158,7 @@ class RestClientTests: XCTestCase { rest.internal.httpExecutor = mockHttpExecutor waitUntil(timeout: testTimeout) { done in - rest.channels.get(uniqueChannelName(for: test)).publish(nil, data: "something") { error in + rest.channels.get(test.uniqueChannelName()).publish(nil, data: "something") { error in XCTAssertNotNil(error) XCTAssertNotNil(error?.requestId) done() diff --git a/Test/Tests/UtilitiesTests.swift b/Test/Tests/UtilitiesTests.swift index e9a70bf19..e1d2a642e 100644 --- a/Test/Tests/UtilitiesTests.swift +++ b/Test/Tests/UtilitiesTests.swift @@ -111,7 +111,7 @@ class UtilitiesTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let realtime = ARTRealtime(options: options) defer { realtime.close() } - let channel = realtime.channels.get(uniqueChannelName(for: test)) + let channel = realtime.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("test", data: NSDate()) { error in guard let error = error else { @@ -141,7 +141,7 @@ class UtilitiesTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let realtime = ARTRealtime(options: options) defer { realtime.close() } - let channel = realtime.channels.get(uniqueChannelName(for: test)) + let channel = realtime.channels.get(test.uniqueChannelName()) // Garbage values (whatever is on the heap) let bytes = UnsafeMutablePointer.allocate(capacity: 1) @@ -178,7 +178,7 @@ class UtilitiesTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let rest = ARTRest(options: options) - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("test", data: NSDate()) { error in guard let error = error else { @@ -209,7 +209,7 @@ class UtilitiesTests: XCTestCase { let rest = ARTRest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor - let channel = rest.channels.get(uniqueChannelName(for: test)) + let channel = rest.channels.get(test.uniqueChannelName()) // Garbage values (whatever is on the heap) let bytes = UnsafeMutablePointer.allocate(capacity: 1) @@ -448,7 +448,7 @@ class UtilitiesTests: XCTestCase { options.logLevel = .verbose let realtime = ARTRealtime(options: options) defer { realtime.close() } - let channel = realtime.channels.get(uniqueChannelName(for: test)) + let channel = realtime.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach { error in