Skip to content

Commit

Permalink
Update a test to use #expect(…, throws:)
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-forooghian committed Dec 3, 2024
1 parent 2c01dfd commit 363e944
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Tests/AblyChatTests/DefaultRoomsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,14 @@ struct DefaultRoomsTests {
_ = try await rooms.get(roomID: roomID, options: options)

// When: get(roomID:options:) is called with the same ID but different options
// Then: It throws an inconsistentRoomOptions error
let differentOptions = RoomOptions(presence: .init(subscribe: false))

let caughtError: Error?
do {
_ = try await rooms.get(roomID: roomID, options: differentOptions)
caughtError = nil
} catch {
caughtError = error
await #expect {
try await rooms.get(roomID: roomID, options: differentOptions)
} throws: { error in
isChatError(error, withCodeAndStatusCode: .fixedStatusCode(.inconsistentRoomOptions))
}

// Then: It throws an inconsistentRoomOptions error
#expect(isChatError(caughtError, withCodeAndStatusCode: .fixedStatusCode(.inconsistentRoomOptions)))
}

// MARK: - Release a room
Expand Down

0 comments on commit 363e944

Please sign in to comment.