prepare tests for throwing readIn/Outbound (#861)

Motivation:

readInbound/Outbound will soon throw errors if the type isn't right.

Modifications:

prepare tests for throwing readIn/Outbound

Result:

@ianpartridge's PR should pretty much merge after this.
This commit is contained in:
Johannes Weiss authored and Cory Benfield committed 2019-03-04 09:40:59 +00:00
1 parent 49659664c2
commit a1981eb0fd
16 files changed
+328 -288

No files matched your search

@@ -34,12 +34,12 @@ class HTTPServerProtocolErrorHandlerTest: XCTestCase {
XCTAssertNoThrow(try channel.closeFuture.wait())
// We expect exactly one ByteBuffer in the output.
guard var written = channel.readOutbound(as: ByteBuffer.self) else {
guard var written = try channel.readOutbound(as: ByteBuffer.self) else {
XCTFail("No writes")
return
}
XCTAssertNil(channel.readOutbound())
XCTAssertNoThrow(XCTAssertNil(try channel.readOutbound()))
// Check the response.
assertResponseIs(response: written.readString(length: written.readableBytes)!,
@@ -76,7 +76,7 @@ class HTTPServerProtocolErrorHandlerTest: XCTestCase {
XCTAssertNoThrow(try channel.writeAndFlush(res).wait())
// now we have started a response but it's not complete yet, let's inject a parser error
channel.pipeline.fireErrorCaught(HTTPParserError.invalidEOFState)
var allOutbound = channel.readAllOutboundBuffers()
var allOutbound = try channel.readAllOutboundBuffers()
let allOutboundString = allOutbound.readString(length: allOutbound.readableBytes)
// there should be no HTTP/1.1 400 or anything in here
XCTAssertEqual("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", allOutboundString)
@@ -127,12 +127,12 @@ class HTTPServerProtocolErrorHandlerTest: XCTestCase {
XCTAssertNoThrow(try channel.closeFuture.wait())
// We expect exactly one ByteBuffer in the output.
guard var written = channel.readOutbound(as: ByteBuffer.self) else {
guard var written = try channel.readOutbound(as: ByteBuffer.self) else {
XCTFail("No writes")
return
}
XCTAssertNil(channel.readOutbound())
XCTAssertNoThrow(XCTAssertNil(try channel.readOutbound()))
// Check the response.
assertResponseIs(response: written.readString(length: written.readableBytes)!,