eyre: improve test ergonomics slightly #7081
Merged
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.
Cookies have been the bane of eyre tests for a while. We had resorted to
hard-coding the couple of expected cookie values and being careful about
passing them in the right place, right time. This was very finicky.
Here, we update the state that's passed continuously to include a value
for the "live" cookie. The rest of the testing code and helpers are
updated to keep this value updated according to the responses emitted by
eyre, and to inject the cookie into requests we simulate. This way, we
get the desired behavior of remembering the cookie like a browser would.
We get to remove the hard-coded cookie values from most tests. In the
process, we clean up the helpers a little bit, but unfortunately also
have to add more complex helpers for pulling the cookie from state.
All in all, tests should be more robust/flexible, at a small complexity
cost. The pattern here (moving over operations, updating & accumulating
state, occasional temporary config changes) might be better implemented as the state machine core (aka abet)
pattern, but that would be a bigger rewrite.
Includes an additional test for #7076, which prompted these changes, and which this PR targets for that reason. Submitting this as a separate PR because it's otherwise unrelated, and should be reviewed in isolation.