mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
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:
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)!,
|
||||
|
||||
Reference in new issue
Block a user