From ca331642c3d031bc0d57f2f66ec6d1f51fad5972 Mon Sep 17 00:00:00 2001 From: Lewis Marshall Date: Thu, 25 Jul 2024 22:52:48 +0100 Subject: [PATCH] tests: Assert error codes rather than messages The error messages are subject to change, but the codes are not, so assert the code instead. Signed-off-by: Lewis Marshall --- Test/Tests/AuthTests.swift | 5 ----- Test/Tests/RealtimeClientConnectionTests.swift | 1 - Test/Tests/RealtimeClientTests.swift | 4 ++-- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Test/Tests/AuthTests.swift b/Test/Tests/AuthTests.swift index 7e89ecb47..8efcc1c9c 100644 --- a/Test/Tests/AuthTests.swift +++ b/Test/Tests/AuthTests.swift @@ -4087,7 +4087,6 @@ class AuthTests: XCTestCase { fail("Reason error is nil"); done(); return } XCTAssertEqual(reason.code, ARTErrorCode.invalidJwtFormat.intValue) - expect(reason.description).to(satisfyAnyOf(contain("invalid signature"), contain("signature verification failed"))) done() } client.connect() @@ -4138,7 +4137,6 @@ class AuthTests: XCTestCase { fail("Reason error is nil"); done(); return } XCTAssertEqual(reason.code, ARTErrorCode.invalidJwtFormat.intValue) - expect(reason.description).to(satisfyAnyOf(contain("invalid signature"), contain("signature verification failed"))) done() } client.connect() @@ -4164,7 +4162,6 @@ class AuthTests: XCTestCase { client.connection.once(.connected) { stateChange in client.connection.once(.disconnected) { stateChange in XCTAssertEqual(stateChange.reason?.code, ARTErrorCode.tokenExpired.intValue) - expect(stateChange.reason?.description).to(contain("Key/token status changed (expire)")) done() } } @@ -4258,7 +4255,6 @@ class AuthTests: XCTestCase { fail("Reason error is nil"); done(); return } XCTAssertEqual(reason.code, ARTErrorCode.invalidJwtFormat.intValue) - expect(reason.description).to(satisfyAnyOf(contain("invalid signature"), contain("signature verification failed"))) done() } client.connect() @@ -4335,7 +4331,6 @@ class AuthTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.channels.get(channelName).publish(messageName, data: nil, callback: { error in XCTAssertEqual(error?.code, ARTErrorCode.operationNotPermittedWithProvidedCapability.intValue) - expect(error?.message).to(contain("permission denied")) done() }) } diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index 2304b6cf7..4c69ff7cd 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -2096,7 +2096,6 @@ class RealtimeClientConnectionTests: XCTestCase { } XCTAssertEqual(reason.code, ARTErrorCode.tokenExpired.intValue) XCTAssertEqual(reason.statusCode, 401) - expect(reason.message).to(contain("Key/token status changed (expire)")) partialDone() } client.connect() diff --git a/Test/Tests/RealtimeClientTests.swift b/Test/Tests/RealtimeClientTests.swift index e47d480a5..6a19d982a 100644 --- a/Test/Tests/RealtimeClientTests.swift +++ b/Test/Tests/RealtimeClientTests.swift @@ -741,10 +741,10 @@ class RealtimeClientTests: XCTestCase { } client.auth.authorize(nil, options: authOptions) { tokenDetails, error in - guard let error = error else { + guard let error = error as? ARTErrorInfo else { fail("ErrorInfo is nil"); partialDone(); return } - expect(error.localizedDescription).to(contain("Invalid accessToken")) + XCTAssertEqual(error.code, ARTErrorCode.invalidCredential.intValue) XCTAssertEqual(tokenDetails?.token, invalidToken) authError = error as NSError? partialDone()