Skip to content

Commit

Permalink
Make all the tests fully async
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne committed Jun 1, 2024
1 parent 34af04e commit 7ce75cc
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 202 deletions.
14 changes: 13 additions & 1 deletion Tests/QueuesTests/AsyncQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import Queues
import XCTest
import XCTVapor

func XCTAssertNoThrowAsync<T>(
_ expression: @autoclosure () async throws -> T,
_ message: @autoclosure () -> String = "",
file: StaticString = #filePath, line: UInt = #line
) async {
do {
_ = try await expression()
} catch {
XCTAssertNoThrow(try { throw error }(), message(), file: file, line: line)
}
}

final class AsyncQueueTests: XCTestCase {
var app: Application!

Expand Down Expand Up @@ -40,7 +52,7 @@ final class AsyncQueueTests: XCTestCase {
XCTAssertEqual(app.queues.test.queue.count, 0)
XCTAssertEqual(app.queues.test.jobs.count, 0)

try XCTAssertNoThrow(promise.futureResult.wait())
await XCTAssertNoThrowAsync(try await promise.futureResult.get())
}
}

Expand Down
Loading

0 comments on commit 7ce75cc

Please sign in to comment.