-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from ably-labs/55-switch-to-swift-testing
[ECO-4990] Switch to Swift Testing
- Loading branch information
Showing
9 changed files
with
107 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import Ably | ||
@testable import AblyChat | ||
import XCTest | ||
|
||
/** | ||
Asserts that a given optional `Error` is an `ARTErrorInfo` in the chat error domain with a given code. | ||
Tests whether a given optional `Error` is an `ARTErrorInfo` in the chat error domain with a given code. | ||
*/ | ||
func assertIsChatError(_ maybeError: (any Error)?, withCode code: AblyChat.ErrorCode, file: StaticString = #filePath, line: UInt = #line) throws { | ||
let error = try XCTUnwrap(maybeError, "Expected an error", file: file, line: line) | ||
let ablyError = try XCTUnwrap(error as? ARTErrorInfo, "Expected an ARTErrorInfo", file: file, line: line) | ||
func isChatError(_ maybeError: (any Error)?, withCode code: AblyChat.ErrorCode) -> Bool { | ||
guard let ablyError = maybeError as? ARTErrorInfo else { | ||
return false | ||
} | ||
|
||
XCTAssertEqual(ablyError.domain, AblyChat.errorDomain as String, file: file, line: line) | ||
XCTAssertEqual(ablyError.code, code.rawValue, file: file, line: line) | ||
XCTAssertEqual(ablyError.statusCode, code.statusCode, file: file, line: line) | ||
return ablyError.domain == AblyChat.errorDomain as String | ||
&& ablyError.code == code.rawValue | ||
&& ablyError.statusCode == code.statusCode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
@testable import AblyChat | ||
import XCTest | ||
import Testing | ||
|
||
class InternalLoggerTests: XCTestCase { | ||
func test_protocolExtension_logMessage_defaultArguments_populatesFileIDAndLine() throws { | ||
struct InternalLoggerTests { | ||
@Test | ||
func protocolExtension_logMessage_defaultArguments_populatesFileIDAndLine() throws { | ||
let logger = MockInternalLogger() | ||
|
||
let expectedLine = #line + 1 | ||
logger.log(message: "Here is a message", level: .info) | ||
|
||
let receivedArguments = try XCTUnwrap(logger.logArguments) | ||
let receivedArguments = try #require(logger.logArguments) | ||
|
||
XCTAssertEqual(receivedArguments.level, .info) | ||
XCTAssertEqual(receivedArguments.message, "Here is a message") | ||
XCTAssertEqual(receivedArguments.codeLocation, .init(fileID: #fileID, line: expectedLine)) | ||
#expect(receivedArguments.level == .info) | ||
#expect(receivedArguments.message == "Here is a message") | ||
#expect(receivedArguments.codeLocation == .init(fileID: #fileID, line: expectedLine)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.