-
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.
The @preconcurrency import of ably-cocoa is temporary and will be removed once [2] is done; created #31 for tracking. Part of #19.
- Loading branch information
1 parent
bc06747
commit 202161b
Showing
7 changed files
with
92 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
import Ably | ||
|
||
public protocol Rooms: AnyObject, Sendable { | ||
func get(roomID: String, options: RoomOptions) throws -> any Room | ||
func release(roomID: String) async throws | ||
var clientOptions: ClientOptions { get } | ||
} | ||
|
||
internal actor DefaultRooms: Rooms { | ||
/// Exposed so that we can test it. | ||
internal nonisolated let realtime: ARTRealtimeProtocol | ||
internal nonisolated let clientOptions: ClientOptions | ||
|
||
internal init(realtime: ARTRealtimeProtocol, clientOptions: ClientOptions) { | ||
self.realtime = realtime | ||
self.clientOptions = clientOptions | ||
} | ||
|
||
internal nonisolated func get(roomID _: String, options _: RoomOptions) throws -> any Room { | ||
fatalError("Not yet implemented") | ||
} | ||
|
||
internal func release(roomID _: String) async throws { | ||
fatalError("Not yet implemented") | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@testable import AblyChat | ||
import XCTest | ||
|
||
class DefaultChatClientTests: XCTestCase { | ||
func test_init_withoutClientOptions() { | ||
// Given: An instance of DefaultChatClient is created with nil clientOptions | ||
let client = DefaultChatClient(realtime: MockRealtime.create(), clientOptions: nil) | ||
|
||
// Then: It uses the default client options | ||
let defaultOptions = ClientOptions() | ||
XCTAssertTrue(client.clientOptions.isEqualForTestPurposes(defaultOptions)) | ||
} | ||
|
||
func test_rooms() throws { | ||
// Given: An instance of DefaultChatClient | ||
let realtime = MockRealtime.create() | ||
let options = ClientOptions() | ||
let client = DefaultChatClient(realtime: realtime, clientOptions: options) | ||
|
||
// Then: Its `rooms` property returns an instance of DefaultRooms with the same realtime client and client options | ||
let rooms = client.rooms | ||
|
||
let defaultRooms = try XCTUnwrap(rooms as? DefaultRooms) | ||
XCTAssertIdentical(defaultRooms.realtime, realtime) | ||
XCTAssertTrue(defaultRooms.clientOptions.isEqualForTestPurposes(options)) | ||
} | ||
} |
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