Skip to content

Commit

Permalink
Fix flaky tests (Resolve #10)
Browse files Browse the repository at this point in the history
  • Loading branch information
blochberger committed Sep 27, 2018
1 parent d9c3ed5 commit a1b73a6
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions PrivacyKitTests/HttpTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ class HttpTests: XCTestCase {
let request = Http.Request(withMethod: .head, andUrl: URL(string: "https://example.com/")!, andHeaders: ["X-Test": "foobar", "X-Foo": "Bar"])!

let actual = String(data: request.composed, encoding: .utf8)!
let expected = "HEAD / HTTP/1.1\r\nX-Test: foobar\r\nHost: example.com\r\nX-Foo: Bar\r\n\r\n"
let expected: Set = [
"HEAD / HTTP/1.1\r\nX-Test: foobar\r\nHost: example.com\r\nX-Foo: Bar\r\n\r\n",
"HEAD / HTTP/1.1\r\nX-Test: foobar\r\nX-Foo: Bar\r\nHost: example.com\r\n\r\n",
"HEAD / HTTP/1.1\r\nHost: example.com\r\nX-Foo: Bar\r\nX-Test: foobar\r\n\r\n",
"HEAD / HTTP/1.1\r\nHost: example.com\r\nX-Test: foobar\r\nX-Foo: Bar\r\n\r\n",
"HEAD / HTTP/1.1\r\nX-Foo: Bar\r\nHost: example.com\r\nX-Test: foobar\r\n\r\n",
"HEAD / HTTP/1.1\r\nX-Foo: Bar\r\nX-Test: foobar\r\nHost: example.com\r\n\r\n"
]

XCTAssertEqual(actual, expected)
XCTAssertTrue(expected.contains(actual))
}

func testConnectRequest() {
Expand All @@ -71,9 +78,16 @@ class HttpTests: XCTestCase {
let request = Http.Request.connect(toTarget: target, viaProxy: proxy, withHeaders: ["X-Test": "foobar", "X-Foo": "Bar"])!

let actual = String(data: request.composed, encoding: .utf8)!
let expected = "CONNECT example.com:80 HTTP/1.1\r\nX-Test: foobar\r\nHost: localhost\r\nX-Foo: Bar\r\n\r\n"
let expected: Set = [
"CONNECT example.com:80 HTTP/1.1\r\nX-Test: foobar\r\nHost: localhost\r\nX-Foo: Bar\r\n\r\n",
"CONNECT example.com:80 HTTP/1.1\r\nX-Test: foobar\r\nX-Foo: Bar\r\nHost: localhost\r\n\r\n",
"CONNECT example.com:80 HTTP/1.1\r\nHost: localhost\r\nX-Foo: Bar\r\nX-Test: foobar\r\n\r\n",
"CONNECT example.com:80 HTTP/1.1\r\nHost: localhost\r\nX-Test: foobar\r\nX-Foo: Bar\r\n\r\n",
"CONNECT example.com:80 HTTP/1.1\r\nX-Foo: Bar\r\nHost: localhost\r\nX-Test: foobar\r\n\r\n",
"CONNECT example.com:80 HTTP/1.1\r\nX-Foo: Bar\r\nX-Test: foobar\r\nHost: localhost\r\n\r\n"
]

XCTAssertEqual(actual, expected)
XCTAssertTrue(expected.contains(actual))
}

func testPServiceUploadResponse() {
Expand Down

0 comments on commit a1b73a6

Please sign in to comment.