Skip to content

Include resp$request in mocked responses #841

@jonthegeek

Description

@jonthegeek

Normal responses get the request field via create_response(), but mocked responses only get the request field if they're errors (via handle_resp()). This means the second (loaded from mock) response doesn't exactly match the "real" response (in this example, loaded via httptest2, which might be the proper place to "fix" this, I'm definitely open to that discussion).

The is_error(resp) branch in handle_resp() currently sets resp$request <- req. If that were either set outside the if or also set in the final else, mocked responses would have the same request objects as their unmocked cousins, regardless of the mock-loader that's being used.

I got the expected result locally by adding resp$request <- req in that final else, and could PR that easily, but I want to check if you have a preference of how to handle this (if at all).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions