Skip to content

Commit 89f9a43

Browse files
committed
Test
1 parent ee1305c commit 89f9a43

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Tests/URLSession+AsyncTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,18 @@ final class URLSessionAsyncTests: XCTestCase {
4747
208
4848
)
4949
}
50+
51+
func testURLSessionFallback_CancelsRequest() async throws {
52+
let request = URLRequest(url: URL(string: "https://httpstat.us/200?sleep=10000")!)
53+
54+
let task = Task {
55+
_ = try await URLSession.shared.makeData(for: request)
56+
}
57+
58+
task.cancel()
59+
60+
await XCTAssertThrowsError(try await task.value, of: URLError.self) {
61+
XCTAssertEqual($0.code, .cancelled)
62+
}
63+
}
5064
}

0 commit comments

Comments
 (0)