Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new mock client to match responses by endpoint #485

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

claudia-correia
Copy link
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • 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

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@claudia-correia claudia-correia added the enhancement New feature or request label Sep 17, 2024
@claudia-correia claudia-correia requested a review from a team as a code owner September 17, 2024 11:05
Copy link

@gersonsosa gersonsosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a great addition, LGTM!

pkg/api/mock.go Show resolved Hide resolved
@claudia-correia claudia-correia merged commit d8b9435 into elastic:master Sep 18, 2024
2 checks passed
@claudia-correia claudia-correia deleted the add-new-mock-client branch September 18, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants