Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Rooms.release non-throwing #188

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/AblyChatExample/Mocks/MockClients.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ actor MockRooms: Rooms {
return room
}

func release(roomID _: String) async throws {
func release(roomID _: String) async {
fatalError("Not yet implemented")
}
lawrence-forooghian marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
4 changes: 2 additions & 2 deletions Sources/AblyChat/Rooms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Ably

public protocol Rooms: AnyObject, Sendable {
func get(roomID: String, options: RoomOptions) async throws -> any Room
func release(roomID: String) async throws
func release(roomID: String) async
var clientOptions: ClientOptions { get }
}

Expand Down Expand Up @@ -258,7 +258,7 @@ internal actor DefaultRooms<RoomFactory: AblyChat.RoomFactory>: Rooms {
}
#endif

internal func release(roomID: String) async throws {
internal func release(roomID: String) async {
guard let roomState = roomStates[roomID] else {
// CHA-RC1g2 (no-op)
return
Expand Down
8 changes: 4 additions & 4 deletions Tests/AblyChatTests/DefaultRoomsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ struct DefaultRoomsTests {
// When: `release(roomID:)` is called with this room ID
// Then: The call to `release(roomID:)` completes (this is as much as I can do to test the spec’s “no-op”; i.e. check it doesn’t seem to wait for anything or have any obvious side effects)
let roomID = "basketball"
try await rooms.release(roomID: roomID)
await rooms.release(roomID: roomID)
}

// @spec CHA-RC1g3
Expand Down Expand Up @@ -290,7 +290,7 @@ struct DefaultRoomsTests {
roomReleaseOperation.complete()

// Then: The second call to `release(roomID:)` completes, and this second release call does not trigger a CHA-RL3 room release operation (i.e. in the language of the spec it reuses the “future” of the existing CHA-RC1g release operation)
try await secondReleaseResult
await secondReleaseResult
#expect(await roomToReturn.releaseCallCount == 1)
}

Expand Down Expand Up @@ -344,7 +344,7 @@ struct DefaultRoomsTests {
roomReleaseOperation.complete()

// Then: The second call to `release(roomID:)` completes, and this second release call does not trigger a CHA-RL3 room release operation (i.e. in the language of the spec it reuses the “future” of the existing CHA-RC1g release operation)
try await secondReleaseResult
await secondReleaseResult
#expect(await roomToReturn.releaseCallCount == 1)
}

Expand All @@ -371,7 +371,7 @@ struct DefaultRoomsTests {
try #require(await rooms.testsOnly_hasRoomMapEntryWithID(roomID))

// When: `release(roomID:)` is called with this room ID
_ = try await rooms.release(roomID: roomID)
_ = await rooms.release(roomID: roomID)

// Then:
// 1. first, the room is removed from the room map
Expand Down
2 changes: 1 addition & 1 deletion Tests/AblyChatTests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ struct IntegrationTests {
// MARK: - Release

// (1) Release the room
try await rxClient.rooms.release(roomID: roomID)
await rxClient.rooms.release(roomID: roomID)

// (2) Check that we received a RELEASED status change as a result of releasing the room
_ = try #require(await rxRoomStatusSubscription.first { $0.current == .released })
Expand Down
Loading