The test should pass - I should be able to compare <<UNORDERED>> arrays having elements with <<PRESENCE>> in them.
What actually happened?
=== RUN TestUNORDEREDwithPRESENCE
prog.go:81: actual JSON at '$.data[0]' contained an unexpected element: {"bar":2,"foo":1}
prog.go:81: actual JSON at '$.data[1]' contained an unexpected element: {"bar":22,"foo":11}
prog.go:81: expected JSON at '$.data[0]':
{"bar":"\u003c\u003cPRESENCE\u003e\u003e","foo":11}
was missing from actual payload
prog.go:81: expected JSON at '$.data[1]':
{"bar":"\u003c\u003cPRESENCE\u003e\u003e","foo":1}
was missing from actual payload
--- FAIL: TestUNORDEREDwithPRESENCE (0.00s)
FAIL
Additional info
Output from go version: go version go1.18.2 darwin/arm64
What exactly did you do?
Compare
<<UNORDERED>>
JSON arrays where the elements are objects and the expectation for some fields only checks for<<PRESENCE>>
.Test example:
See test examples with some sanity in this Go Playground.
What did you expect would happen?
The test should pass - I should be able to compare
<<UNORDERED>>
arrays having elements with<<PRESENCE>>
in them.What actually happened?
Additional info
go version
:go version go1.18.2 darwin/arm64
v.1.1.0
As can be seen in the Go Playground example, I did some sanity tests, and it seems that
<<UNORDERED>>
and<<PRESENCE>>
work well for the example above, except for when they are mixed together. Looking in the code, it seems to be caused by. the difference betweenAsserter.checkArrayUnordered
andAsserter.checkArrayOrdered
. The unordered version usesAsserter.deepEqual
, whereas the ordered version usesAsserter.pathassertf
.