Skip to content

Commit 715ab14

Browse files
committed
fix missing ELG close in test
1 parent 7f31443 commit 715ab14

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

Diff for: Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,8 @@ class HTTPClientInternalTests: XCTestCase {
949949

950950
defer {
951951
XCTAssertNoThrow(try client.syncShutdown())
952-
XCTAssertNoThrow(try elg.syncShutdownGracefully())
953952
XCTAssertNoThrow(try httpBin.shutdown())
953+
XCTAssertNoThrow(try elg.syncShutdownGracefully())
954954
}
955955

956956
let request = try HTTPClient.Request(url: "http://localhost:\(httpBin.port)//get")

Diff for: Tests/AsyncHTTPClientTests/HTTPClientTests.swift

+23-8
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,7 @@ class HTTPClientTests: XCTestCase {
20382038
defer {
20392039
XCTAssertNoThrow(try httpClient.syncShutdown())
20402040
XCTAssertNoThrow(try httpServer.stop())
2041+
XCTAssertNoThrow(try elg.syncShutdownGracefully())
20412042
}
20422043

20432044
let delegate = TestDelegate(eventLoop: second)
@@ -2069,10 +2070,17 @@ class HTTPClientTests: XCTestCase {
20692070
XCTAssertEqual(error as! HTTPClientError, HTTPClientError.bodyLengthMismatch)
20702071
}
20712072
// Quickly try another request and check that it works.
2072-
var response = try self.defaultClient.get(url: self.defaultHTTPBinURLPrefix + "get").wait()
2073-
let info = try response.body!.readJSONDecodable(RequestInfo.self, length: response.body!.readableBytes)
2074-
XCTAssertEqual(info!.connectionNumber, 1)
2075-
XCTAssertEqual(info!.requestNumber, 1)
2073+
let response = try self.defaultClient.get(url: self.defaultHTTPBinURLPrefix + "get").wait()
2074+
guard var body = response.body else {
2075+
XCTFail("Body missing: \(response)")
2076+
return
2077+
}
2078+
guard let info = try body.readJSONDecodable(RequestInfo.self, length: body.readableBytes) else {
2079+
XCTFail("Cannot parse body: \(body.readableBytesView.map { $0 })")
2080+
return
2081+
}
2082+
XCTAssertEqual(info.connectionNumber, 1)
2083+
XCTAssertEqual(info.requestNumber, 1)
20762084
}
20772085

20782086
// currently gets stuck because of #250 the server just never replies
@@ -2089,9 +2097,16 @@ class HTTPClientTests: XCTestCase {
20892097
}
20902098
// Quickly try another request and check that it works. If we by accident wrote some extra bytes into the
20912099
// stream (and reuse the connection) that could cause problems.
2092-
var response = try self.defaultClient.get(url: self.defaultHTTPBinURLPrefix + "get").wait()
2093-
let info = try response.body!.readJSONDecodable(RequestInfo.self, length: response.body!.readableBytes)
2094-
XCTAssertEqual(info!.connectionNumber, 1)
2095-
XCTAssertEqual(info!.requestNumber, 1)
2100+
let response = try self.defaultClient.get(url: self.defaultHTTPBinURLPrefix + "get").wait()
2101+
guard var body = response.body else {
2102+
XCTFail("Body missing: \(response)")
2103+
return
2104+
}
2105+
guard let info = try body.readJSONDecodable(RequestInfo.self, length: body.readableBytes) else {
2106+
XCTFail("Cannot parse body: \(body.readableBytesView.map { $0 })")
2107+
return
2108+
}
2109+
XCTAssertEqual(info.connectionNumber, 1)
2110+
XCTAssertEqual(info.requestNumber, 1)
20962111
}
20972112
}

0 commit comments

Comments
 (0)