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
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Refactoring (improves code quality but has no user-facing effect)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
[ ] Documentation
Readiness Checklist
[x] My code follows the code style of this project
[ ] My change requires a change to the documentation
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