mirror of https://github.com/vapor/docs.git
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:
parent
62a7b6c35a
commit
a0c7fd2137
|
|
@ -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/).
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue