Skip to content

Commit acc0f9c

Browse files
committed
fix(ios): assert async throws with do/catch, not XCTAssertThrowsError
XCTAssertThrowsError's autoclosure cannot hold `await`; use a do/catch to drive the async throw and check the error type.
1 parent 4099e59 commit acc0f9c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

swift/CascadeFileProvideriOS/Tests/CascadeIntegrationTests.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ final class CascadeIntegrationTests: XCTestCase {
4040
let node = try await CascadeNode(configDir: configDir)
4141
try await node.start()
4242

43-
XCTAssertThrowsError(try await node.readFile(path: "/local/absent.txt")) { error in
44-
// The FFI maps an engine error onto CascadeError; the read of a
45-
// missing file must surface an error, not an empty body or a crash.
43+
// XCTAssertThrowsError's autoclosure cannot hold `await`, so drive the
44+
// async throw by hand. The FFI maps an engine error onto CascadeError;
45+
// the read of a missing file must surface an error, not an empty body.
46+
do {
47+
_ = try await node.readFile(path: "/local/absent.txt")
48+
XCTFail("reading a missing file should throw")
49+
} catch {
4650
XCTAssertTrue(error is CascadeError, "missing file is a CascadeError: \(error)")
4751
}
4852
}

0 commit comments

Comments
 (0)