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 http request mocking support #235

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

swissspidy
Copy link
Member

@swissspidy swissspidy commented Jan 26, 2025

Fixes #210

@swissspidy swissspidy requested a review from a team as a code owner January 26, 2025 20:24
@swissspidy swissspidy mentioned this pull request Jan 26, 2025
1 task
@swissspidy
Copy link
Member Author

@BrianHenryIE Would love to hear your thoughts on this especially :-)

Note:The original suggestion was to store the mocked responses in files and use those, but this can be achieved with this solution just as well.

Example:

  Background:
    When I run `cat my/mocked/response.json`
    Then save STDOUT as {HTTP_RESPONSE}

  Scenario: Mock HTTP request in WP-CLI
    Given an empty directory
    And an HTTP request to https://api.github.com/repos/wp-cli/wp-cli/releases?per_page=100 with this response:
    """
    HTTP/1.1 200
    Content-Type: application/json

    {HTTP_RESPONSE}
    """

I haven't tested that though, but I could add a test for it.

@swissspidy
Copy link
Member Author

By the way this has already been successfully tested as part of wp-cli/wp-cli#6037, so I think it's good to go.

Appreciate a good review though :)

@swissspidy swissspidy added this to the 4.3.7 milestone Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mock HTTP requests
1 participant