Skip to content

Commit

Permalink
Make Rooms.release non-throwing
Browse files Browse the repository at this point in the history
Mistake in 20e7f5f.
  • Loading branch information
lawrence-forooghian committed Dec 10, 2024
1 parent 76984aa commit 543a4f8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
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")
}

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

0 comments on commit 543a4f8

Please sign in to comment.