You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
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
+
finalclassUserCreationServiceTests: XCTestCase {
454
+
var app: Application!
455
+
456
+
overridefuncsetUp() asyncthrows {
457
+
self.app=tryawait Application.make(.testing)
458
+
tryawaitconfigure(app)
459
+
460
+
// Override the driver being used for testing
461
+
app.queues.use(.asyncTest)
462
+
}
463
+
464
+
overridefunctearDown() asyncthrows {
465
+
tryawaitself.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/).
0 commit comments