Provide a way to steer the router state machine during integration tests. #3099
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This changeset provides a new
TestRouterHttpServer
with a couple of interesting functions for us to write "semi" integrated tests.Why?
This will allow us to make sure the router updates as expected if configuration, schema and entitlements change.
Ok this sounds great but how do I...
Create a TestRouterHttpServer?
Add your test to
apollo-router/src/router.rs
:Get the router to start?
It will need a valid configuration, a valid schema, and valid entitlements:
Send requests to the router?
Get the router to shut down once my tests have passed ?
You can now have fine grained control over the sequence of events that are processed by the router, and write the relevant regression tests.
That's it! No more excuses!