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

Problem dealing with null value #2

Closed
yookoala opened this issue Aug 16, 2014 · 1 comment
Closed

Problem dealing with null value #2

yookoala opened this issue Aug 16, 2014 · 1 comment
Assignees
Labels

Comments

@yookoala
Copy link
Collaborator

While using restit with one of my project, an uncanny bug comes out when the system gets a JSON response like this:

{"Status": "OK", "Results": null}

The Results field is supposed to be an array. The problem comes when I tried to decode the above respose to this structure:

type MyResponse struct {
    Status  string
    Results []Item
}

Turns out that when encountering a null value in Results, json decoder wouldn't do anything to the existing field. So when I reuse a MyResponse variable over several tests, some test fails when the current JSON is null and there are previous value in MyResponse.Results field.

restit needs to reset the result at the beginning of the test (when Run or RunOrPanic).

@yookoala yookoala added the bug label Aug 16, 2014
@yookoala yookoala self-assigned this Aug 16, 2014
yookoala added a commit that referenced this issue Aug 16, 2014
The `Response` interface now requires an additional `Reset` method.
`Run` and `RunOrPanic` will trigger this `Reset` method at the
beginning.

This will fix bug #2.
yookoala added a commit that referenced this issue Aug 16, 2014
The `Response` interface now requires an additional `Reset` method.
`Run` and `RunOrPanic` will trigger this `Reset` method at the
beginning.

This will fix bug #2.
@yookoala
Copy link
Collaborator Author

Bug fixed.

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

No branches or pull requests

1 participant