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

@@ -133,7 +133,7 @@ class HTTPDecoderLengthTest: XCTestCase {
// Prime the decoder with a GET and consume it.
XCTAssertTrue(try channel.writeOutbound(HTTPClientRequestPart.head(HTTPRequestHead(version: version, method: .GET, uri: "/"))))
XCTAssertNotNil(channel.readOutbound(as: ByteBuffer.self))
XCTAssertNoThrow(XCTAssertNotNil(try channel.readOutbound(as: ByteBuffer.self)))
// We now want to send a HTTP/1.1 response. This response has no content-length, no transfer-encoding,
// is not a response to a HEAD request, is not a 2XX response to CONNECT, and is not 1XX, 204, or 304.
@@ -198,7 +198,7 @@ class HTTPDecoderLengthTest: XCTestCase {
XCTAssertTrue(try channel.writeOutbound(HTTPClientRequestPart.head(HTTPRequestHead(version: .init(major: 1, minor: 1),
method: requestMethod,
uri: "/"))))
XCTAssertNotNil(channel.readOutbound(as: ByteBuffer.self))
XCTAssertNoThrow(XCTAssertNotNil(try channel.readOutbound(as: ByteBuffer.self)))
// We now want to send a HTTP/1.1 response. This response may contain some length framing fields that RFC 7230 says MUST
// be ignored.
@@ -337,7 +337,7 @@ class HTTPDecoderLengthTest: XCTestCase {
XCTAssertTrue(try channel.writeOutbound(HTTPClientRequestPart.head(HTTPRequestHead(version: .init(major: 1, minor: 1),
method: .GET,
uri: "/"))))
XCTAssertNotNil(channel.readOutbound(as: ByteBuffer.self))
XCTAssertNoThrow(XCTAssertNotNil(try channel.readOutbound(as: ByteBuffer.self)))
// Send a 200 with the appropriate Transfer Encoding header. We should see the request,
// but no body or end.