-
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.
We want to be able to mock out the upcoming `Room.release()` method.
- Loading branch information
1 parent
ac92127
commit c51fd92
Showing
7 changed files
with
117 additions
and
26 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
@testable import AblyChat | ||
|
||
actor MockRoom: Room { | ||
let options: RoomOptions | ||
|
||
init(options: RoomOptions) { | ||
self.options = options | ||
} | ||
|
||
nonisolated var roomID: String { | ||
fatalError("Not implemented") | ||
} | ||
|
||
nonisolated var messages: any Messages { | ||
fatalError("Not implemented") | ||
} | ||
|
||
nonisolated var presence: any Presence { | ||
fatalError("Not implemented") | ||
} | ||
|
||
nonisolated var reactions: any RoomReactions { | ||
fatalError("Not implemented") | ||
} | ||
|
||
nonisolated var typing: any Typing { | ||
fatalError("Not implemented") | ||
} | ||
|
||
nonisolated var occupancy: any Occupancy { | ||
fatalError("Not implemented") | ||
} | ||
|
||
var status: AblyChat.RoomStatus { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func onStatusChange(bufferingPolicy _: BufferingPolicy) async -> Subscription<RoomStatusChange> { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func attach() async throws { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func detach() async throws { | ||
fatalError("Not implemented") | ||
} | ||
} |
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,20 @@ | ||
@testable import AblyChat | ||
|
||
actor MockRoomFactory: RoomFactory { | ||
private let room: MockRoom? | ||
private(set) var createRoomArguments: (realtime: RealtimeClient, chatAPI: ChatAPI, roomID: String, options: RoomOptions, logger: any InternalLogger)? | ||
|
||
init(room: MockRoom? = nil) { | ||
self.room = room | ||
} | ||
|
||
func createRoom(realtime: RealtimeClient, chatAPI: ChatAPI, roomID: String, options: RoomOptions, logger: any InternalLogger) async throws -> MockRoom { | ||
createRoomArguments = (realtime: realtime, chatAPI: chatAPI, roomID: roomID, options: options, logger: logger) | ||
|
||
guard let room else { | ||
fatalError("MockRoomFactory.createRoom called, but the mock factory has not been set up with a room to return") | ||
} | ||
|
||
return room | ||
} | ||
} |