-
Notifications
You must be signed in to change notification settings - Fork 8
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
json unmarshaling asserts an error when using json Encoding #34
Comments
Thanks for pointing this out! Was able to reproduce. This seems to be the culprit --> Line 46 in d831b87
The below change should make it work: lines := strings.Split(strings.TrimSpace(data), "\n") I'm inclined to use the built in http dump unless there is a desire to include information which is not provided by that method. |
resolve error when using json encoder, fixes #34
thanks for the quick turnaround. there's definitely some information lost, but I think for the purposes of the snapshot makes sense! |
The hard coded implementation in assert.go for parsing json responses breaks when using
json.NewEncoder([insert-my-struct]).Enocde(w)
. It asserts thatTo reproduce:
if you call assert http response on the above in some test:
abide.AssertHTTPResponse(t, name, w.Result())
, assert will return an error forunexpected end of JSON input
. This is because there's a new line that seems to be returned fromhttputil.DumpResponse
on the json response when usingNewEncoder
vs usingjson.Marshal
and writing bytes.assert.go seems to be manually parsing the lines to determine the body, instead it probably makes more sense to actually read the properties from the response rather than the dump from httputil (I think there are a few cases where the dump won't always be consistent - but can't remember off the top of my head)
The text was updated successfully, but these errors were encountered: