Skip to content

Commit a0c7fd2

Browse files
Dracksgwynne
andauthored
Improved the queues.md page to add a little extra info about testing (#1008)
<!-- 🚀 Thank you for contributing! --> <!-- Describe your changes clearly and use examples if possible. --> * Added a small brief of the asyncDriver to allow people know you can use that for testing <!-- When this PR is merged, the title and body will be --> <!-- used to generate a release automatically. --> --------- Co-authored-by: Gwynne Raskind <[email protected]>
1 parent 62a7b6c commit a0c7fd2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/advanced/queues.md

+27
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,30 @@ There are a number of third-party packages that use the delegate functionality t
444444

445445
- [QueuesDatabaseHooks](https://github.com/vapor-community/queues-database-hooks)
446446
- [QueuesDash](https://github.com/gotranseo/queues-dash)
447+
448+
## Testing
449+
450+
To avoid synchronization problems and ensure deterministic testing, the Queues package provides an `XCTQueue` library and an `AsyncTestQueuesDriver` driver dedicated to testing which you can use as follows:
451+
452+
```swift
453+
final class UserCreationServiceTests: XCTestCase {
454+
var app: Application!
455+
456+
override func setUp() async throws {
457+
self.app = try await Application.make(.testing)
458+
try await configure(app)
459+
460+
// Override the driver being used for testing
461+
app.queues.use(.asyncTest)
462+
}
463+
464+
override func tearDown() async throws {
465+
try await self.app.asyncShutdown()
466+
self.app = nil
467+
}
468+
}
469+
```
470+
471+
See more details in [Romain Pouclet's blog post](https://romain.codes/2024/10/08/using-and-testing-vapor-queues/).
472+
473+

0 commit comments

Comments
 (0)