Skip to content

Commit bcb1c4f

Browse files
committed
Fix TestURLSession.test_noDoubleCallbackWhenCancellingAndProtocolFailsFast()
- Darwin requires implementation of FailFastProtocol.canonicalRequest() to override abstract method in URLProtocol - Fix the error code from in the callback to be equal to NSURLErrorCancelled. - This test now passes on Darwin and Linux but is currently left disabled.
1 parent e7797a0 commit bcb1c4f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Tests/Foundation/Tests/TestURLSession.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ class TestURLSession : LoopbackServerTest {
10041004
callbackCount += 1
10051005
XCTAssertNotNil(error)
10061006
if let urlError = error as? URLError {
1007-
XCTAssertNotEqual(urlError._nsError.code, NSURLErrorCancelled)
1007+
XCTAssertEqual(urlError._nsError.code, NSURLErrorCancelled)
10081008
}
10091009

10101010
if callbackCount == 1 {
@@ -1405,6 +1405,10 @@ class FailFastProtocol: URLProtocol {
14051405
return request.url?.scheme == "failfast"
14061406
}
14071407

1408+
override class func canonicalRequest(for request: URLRequest) -> URLRequest {
1409+
return request
1410+
}
1411+
14081412
override class func canInit(with task: URLSessionTask) -> Bool {
14091413
guard let request = task.currentRequest else { return false }
14101414
return canInit(with: request)

0 commit comments

Comments
 (0)