Make the ContentApiQuery type convariant in Response #429
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.
What does this change?
Changes the
Response
type parameter from invarant to covariant.This is to make pattern-matching in tests to work better - used in integration tests introduced with https://github.com/guardian/crier/pull/169.
In a nutshell, we needed to be able to use Mockito to verify two different calls to the library. If the calls changed order, the behaviour would still be correct (ordering cannot be guaranteed in this case) but the test would then fail if it tried to cast the
SearchQuery
to theItemQuery
or vice-versa.With this update in place, we can make a correctly scoped
match
statement to handle both of these cases gracefully:Without this update, the compiler objects since the type signature of
ContentApiQuery[Response]
requires specific response type and not an ancestor of this type. When changed toContentApiQuery[+Response]
we are able to successfully match against any possible value.How to test
Integration tests linked above work.
Tested locally.
How can we measure success?
Able to continue on Crier
Have we considered potential risks?
n/a