File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Tests/AsyncHTTPClientTests Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ class HTTPClientNIOTSTests: XCTestCase {
104104
105105 func testConnectionFailError( ) {
106106 guard isTestingNIOTS ( ) else { return }
107+ #if canImport(Network)
107108 let httpBin = HTTPBin ( . http1_1( ssl: false ) )
108109 let httpClient = HTTPClient ( eventLoopGroupProvider: . shared( self . clientGroup) ,
109110 configuration: . init( timeout: . init( connect: . milliseconds( 100 ) ,
@@ -117,8 +118,15 @@ class HTTPClientNIOTSTests: XCTestCase {
117118 XCTAssertNoThrow ( try httpBin. shutdown ( ) )
118119
119120 XCTAssertThrowsError ( try httpClient. get ( url: " http://localhost: \( port) /get " ) . wait ( ) ) {
120- XCTAssertEqual ( $0 as? HTTPClientError , . connectTimeout)
121+ if let httpClientError = $0 as? HTTPClientError {
122+ XCTAssertEqual ( httpClientError, . connectTimeout)
123+ } else if let posixError = $0 as? HTTPClient . NWPOSIXError {
124+ XCTAssertEqual ( posixError. errorCode, . ECONNREFUSED)
125+ } else {
126+ XCTFail ( " unexpected error \( $0) " )
127+ }
121128 }
129+ #endif
122130 }
123131
124132 func testTLSVersionError( ) {
You can’t perform that action at this time.
0 commit comments