Open Metamogul opened 2 weeks ago
Yeah I can't see why we need to even check the value is 0
in the int
-like cases. In the case of a floating point number, 0.0
when sent over the wire (i.e. as JSON) is implementation dependent and may get sent as 0
- so we defer to a non-zero number there to preserve the floating point.
I'm open to a PR that allows zero though because ultimately, the user can just update the test to a different number should the downscaling occur.
Software versions
pact-go@2.0.4
Expected behaviour
If I define a struct like
and use it in building an interaction response such as
I'd expect these values to be reflected in the response body in the json pact files like
Actual behaviour
Instead, the example for the float with the specified example value
0
is set to1.1
:This is caused by the following implementation in
matchers/matcher.go:328
:Obviously the problem affects floats and ints alike. A simple fix seems to be to
return Like(0)
as default orreturn Like(0.0)
respectively. However I've just discovered the problem and my knowledge of the pact-go codebase is not deep enough to foresee the consequences of this change, so I didn't create PR yet. Could anybody more experienced comment on this?Steps to reproduce
Use the interaction builder with a response as specified above and observe the generated pact files response body.