Skip to content

Commit

Permalink
Merge pull request #2006 from ably/2025-08-01-fix-tests
Browse files Browse the repository at this point in the history
Fix some test failures that result from Realtime error changes
  • Loading branch information
lawrence-forooghian authored Jan 9, 2025
2 parents f5749dd + 0a3caf4 commit 23485fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Test/Tests/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class AuthTests: XCTestCase {
guard let errorInfo = stateChange.reason else {
fail("ErrorInfo is nil"); done(); return
}
expect(errorInfo.message).to(contain("No application found with id"))
expect(errorInfo.code).to(equal(ARTErrorCode.invalidCredentials.intValue))
done()
}
realtime.connection.once(.disconnected) { _ in
Expand Down
3 changes: 2 additions & 1 deletion Test/Tests/RealtimeClientConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4132,7 +4132,8 @@ class RealtimeClientConnectionTests: XCTestCase {
guard let error = stateChange.reason else {
fail("Error is nil"); done(); return
}
XCTAssertTrue(error.code == ARTErrorCode.invalidCredential.rawValue)
// This is because, at time of writing, the production environment is handling connections using both frontend (which returns invalidCredential) and frontdoor (which returns invalidCredentials). So we need to handle both cases at least for now (unlike other tests, which use sandbox which is 100% using frontdoor).
XCTAssertTrue(error.code == ARTErrorCode.invalidCredential.rawValue || error.code == ARTErrorCode.invalidCredentials.rawValue)
done()
}
}
Expand Down
4 changes: 2 additions & 2 deletions Test/Tests/RestClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class RestClientTests: XCTestCase {

let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false)

expect(publishTask.error?.code).toEventually(equal(ARTErrorCode.invalidCredential.intValue), timeout: testTimeout)
expect(publishTask.error?.code).toEventually(equal(ARTErrorCode.invalidCredentials.intValue), timeout: testTimeout)
}

func test__018__RestClient__initializer__should_accept_a_token() throws {
Expand Down Expand Up @@ -234,7 +234,7 @@ class RestClientTests: XCTestCase {

let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false)

expect(publishTask.error?.code).toEventually(equal(ARTErrorCode.invalidCredential.intValue), timeout: testTimeout)
expect(publishTask.error?.code).toEventually(equal(ARTErrorCode.invalidCredentials.intValue), timeout: testTimeout)
}

// RSC2
Expand Down

0 comments on commit 23485fa

Please sign in to comment.