Add new mock client to match responses by endpoint #485
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.
Description
Adds a new mock client to match a set of responses per endpoint. The match is done using a regex.
Related Issues
https://elasticco.atlassian.net/browse/CP-7863
Motivation and Context
In PR https://github.com/elastic/cloud-cli/pull/1525, I added some unit tests that are currently failing because they're using the default Round Tripper client. This client provides the responses in the order they're defined. However, in those tests we're not sure in which order the requests are executed, because they're performed by different go routines running concurrently. This new client allows to provide a set of responses per endpoint, by specifying an endpoint regex as the key to a map and a set of responses as the value.
How Has This Been Tested?
Types of Changes
Readiness Checklist