Skip to content

Commit

Permalink
tests: Assert error codes rather than messages
Browse files Browse the repository at this point in the history
The error messages are subject to change, but the codes are not, so
assert the code instead.

Signed-off-by: Lewis Marshall <[email protected]>
  • Loading branch information
lmars committed Jul 27, 2024
1 parent e565523 commit ca33164
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
5 changes: 0 additions & 5 deletions Test/Tests/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
}
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
})
}
Expand Down
1 change: 0 additions & 1 deletion Test/Tests/RealtimeClientConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions Test/Tests/RealtimeClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ca33164

Please sign in to comment.