From d11484846ed64d45834037dfb1bfe2349f9b47fa Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Fri, 31 May 2024 18:17:46 +0100 Subject: [PATCH] Proper async test to ensure the new APIs are hit --- Tests/QueuesTests/AsyncQueueTests.swift | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Tests/QueuesTests/AsyncQueueTests.swift b/Tests/QueuesTests/AsyncQueueTests.swift index 7c6c732..7c0f42e 100644 --- a/Tests/QueuesTests/AsyncQueueTests.swift +++ b/Tests/QueuesTests/AsyncQueueTests.swift @@ -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) @@ -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") } @@ -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)