From a1b73a6dd5a61a4a07e216bc11ea89f8f5c2f54b Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Thu, 27 Sep 2018 11:32:53 +0200 Subject: [PATCH] Fix flaky tests (Resolve #10) --- PrivacyKitTests/HttpTests.swift | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/PrivacyKitTests/HttpTests.swift b/PrivacyKitTests/HttpTests.swift index c4ef604..7004d27 100644 --- a/PrivacyKitTests/HttpTests.swift +++ b/PrivacyKitTests/HttpTests.swift @@ -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() { @@ -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() {