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

Unable to change response code when mocking with JSON #100

Closed
daneov opened this issue Jul 25, 2018 · 1 comment
Closed

Unable to change response code when mocking with JSON #100

daneov opened this issue Jul 25, 2018 · 1 comment

Comments

@daneov
Copy link
Contributor

daneov commented Jul 25, 2018

In our backend we employ JSON error responses to inform the client of what went wrong exactly.
This can be a missing field (400), which would then contain a body like:

{
    "error_code" : "missing_field_y"
}

In order to verify that the app correctly passes this information, I'm writing a test to verify that the parsing goes correctly.

However, when creating a Mock object the following way, it seems to default to a successful response.

let provider = MockProvider<HTTPMethod> { _ in
            return Mock(json: ["error_code": errorCode])
        }

Do you have any suggestions on how to work around this?

(P.S. It's also inconvenient that passing data encoded with Swift 4's JSONEncoder is not working but results in an invalid_api_response)

@vadymmarkov
Copy link
Owner

Should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants