Skip to content

Commit

Permalink
Merge pull request #37 from outfoxx/fix/flaky-test
Browse files Browse the repository at this point in the history
Fix flaky chunked tests
  • Loading branch information
kdubb authored Dec 8, 2022
2 parents 78fa0f2 + 4e2ec21 commit 7eeb4b3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Tests/SundayTests/DataTaskStreamPublisherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ class DataTaskStreamPublisherTests: XCTestCase {
Path("/regular") {
GET { _, res in
res.start(status: .ok, headers: [:])
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 1)) {
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 0)) {
res.send(body: Data(count: 1000), final: false)
}
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 2)) {
res.send(body: Data(count: 1000), final: false)
}
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 3)) {
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 4)) {
res.send(body: Data(count: 1000), final: false)
}
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 4)) {
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 6)) {
res.send(body: Data(count: 1000), final: true)
}
}
Expand Down Expand Up @@ -91,19 +91,19 @@ class DataTaskStreamPublisherTests: XCTestCase {
res.start(status: .ok, headers: [
HTTP.StdHeaders.transferEncoding: ["chunked"],
])
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 1)) {
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 0)) {
res.send(chunk: Data(count: 1000))
}
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 2)) {
res.send(chunk: Data(count: 1000))
}
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 3)) {
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 4)) {
res.send(chunk: Data(count: 1000))
}
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 4)) {
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 6)) {
res.send(chunk: Data(count: 1000))
}
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 5)) {
res.server.queue.asyncAfter(deadline: .now() + .milliseconds(500 * 8)) {
res.finish(trailers: [:])
}
}
Expand Down

0 comments on commit 7eeb4b3

Please sign in to comment.