-
Notifications
You must be signed in to change notification settings - Fork 55
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
JSONKeyEqual
will give confusing error message when comparing JSON numbers
#278
Comments
Bleh, thanks for pointing this out. Agreed, test writers should not need to know or care about this. |
I got tripped up by this again today: PLContent := map[string]interface{}{
"invite": 100,
"users": map[string]interface{}{
alice.UserID: 100,
},
}
eventId := alice.SendEventSynced(t, roomID, b.Event{
Type: "m.room.power_levels",
StateKey: b.Ptr(""),
Content: PLContent,
})
res := alice.MustDoFunc(
t,
"GET",
[]string{"_matrix", "client", "v3", "rooms", roomID, "event", eventId},
)
must.MatchResponse(t, res, match.HTTPResponse{
JSON: []match.JSON{
match.JSONKeyEqual("content", PLContent),
},
})
This fails because the integer inside the powerlevel event's content is converted to float64, so doing a roundtrip is not possible. |
One thing we can do is do a canonicalisation roundtrip by |
This is when using
JSONKeyEqual
on amatch.JSON
array.Changing the error message section to the following;
Yields this more useful error message;
This behaviour should probably be accounted for when extracting values with
JSONKeyEqual
, so eitherJSONKeyEqual
will have to coerce all numerical types intofloat64
, or give this above more-clear error message.The text was updated successfully, but these errors were encountered: