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 <gwynne@darkrainfall.org>
This commit is contained in:
Jaume 2024-11-03 23:59:05 +01:00 committed by GitHub
parent 62a7b6c35a
commit a0c7fd2137
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 0 deletions

View File

@ -444,3 +444,30 @@ There are a number of third-party packages that use the delegate functionality t
- [QueuesDatabaseHooks](https://github.com/vapor-community/queues-database-hooks)
- [QueuesDash](https://github.com/gotranseo/queues-dash)
## Testing
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:
```swift
final class UserCreationServiceTests: XCTestCase {
var app: Application!
override func setUp() async throws {
self.app = try await Application.make(.testing)
try await configure(app)
// Override the driver being used for testing
app.queues.use(.asyncTest)
}
override func tearDown() async throws {
try await self.app.asyncShutdown()
self.app = nil
}
}
```
See more details in [Romain Pouclet's blog post](https://romain.codes/2024/10/08/using-and-testing-vapor-queues/).