Skip to content

Commit 3725095

Browse files
authored
Fix flaky HTTPClientTests.testResponseDelayGet() test (#584)
1 parent 89b0da2 commit 3725095

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.swiftformat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
--disable redundantReturn
2020
--disable preferKeyPath
2121
--disable sortedSwitchCases
22+
--disable numberFormatting
2223

2324
# rules

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,9 +1216,9 @@ class HTTPClientTests: XCTestCase {
12161216
method: .GET,
12171217
headers: ["X-internal-delay": "2000"],
12181218
body: nil)
1219-
let start = Date()
1220-
let response = try! self.defaultClient.execute(request: req).wait()
1221-
XCTAssertGreaterThan(Date().timeIntervalSince(start), 2)
1219+
let start = NIODeadline.now()
1220+
let response = try self.defaultClient.execute(request: req).wait()
1221+
XCTAssertGreaterThanOrEqual(.now() - start, .milliseconds(1_900 /* 1.9 seconds */ ))
12221222
XCTAssertEqual(response.status, .ok)
12231223
}
12241224

0 commit comments

Comments
 (0)