Skip to content

Commit

Permalink
Proper async test to ensure the new APIs are hit
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed May 31, 2024
1 parent 573fcbb commit d114848
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Tests/QueuesTests/AsyncQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ import NIOCore
import NIOConcurrencyHelpers

final class AsyncQueueTests: XCTestCase {
func testAsyncJob() throws {
let app = Application(.testing)
defer { app.shutdown() }
var app: Application!

override func setUp() async throws {
app = try await Application.make(.testing)
}

override func tearDown() async throws {
try await app.asyncShutdown()
}

func testAsyncJob() async throws {
app.queues.use(.test)

let promise = app.eventLoopGroup.any().makePromise(of: Void.self)
Expand All @@ -22,7 +30,7 @@ final class AsyncQueueTests: XCTestCase {
.map { _ in "done" }
}

try app.testable().test(.GET, "foo") { res in
try await app.testable().test(.GET, "foo") { res async in
XCTAssertEqual(res.status, .ok)
XCTAssertEqual(res.body.string, "done")
}
Expand All @@ -34,7 +42,7 @@ final class AsyncQueueTests: XCTestCase {
XCTAssertNotNil(job)
XCTAssertEqual(job!.foo, "bar")

try app.queues.queue.worker.run().wait()
try await app.queues.queue.worker.run().get()
XCTAssertEqual(app.queues.test.queue.count, 0)
XCTAssertEqual(app.queues.test.jobs.count, 0)

Expand Down

0 comments on commit d114848

Please sign in to comment.