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

Float/Int mismatch #93

Closed
alexplischke opened this issue Jul 31, 2018 · 4 comments
Closed

Float/Int mismatch #93

alexplischke opened this issue Jul 31, 2018 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@alexplischke
Copy link

alexplischke commented Jul 31, 2018

Software versions

  • OS: e.g. Mac OSX 10.13.6
  • Consumer Pact library: e.g. Pact go v0.0.13
  • Provider Pact library: e.g. Pact go v0.0.13
  • Golang Version: go1.10.2 darwin/amd64
  • Golang environment: GOARCH="amd64" GOBIN="" GOCACHE="/Users/alexplischke/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/alexplischke/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.10.2/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.10.2/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/qh/nfnj30bn06z5rgb84b0nlb280000gn/T/go-build420646863=/tmp/go-build -gno-record-gcc-switches -fno-common"

Expected behaviour

I have a struct with a field "foo" of type float64. Pact generates a contract with the following statement "foo": 1.0.

Actual behaviour

Pact generates a contract with the following statement "foo": 1. This causes the verification to fail, when the actual response is a float and not as pact generated, an int.

Steps to reproduce

Create a struct with a float64 (or float32) field and match the struct via Body: dsl.Match(&YourStruct{}).

Relevant log lines

    		Diff
    		--------------------------------------
    		Key: - is expected
    		     + is actual
    		Matching keys and values are not shown

    		 {
    		   "files": [
    		     {
    		-      "foo": Fixnum
    		+      "foo": Float
    		     }
    		   ]
    		 }

    		Description of differences
    		--------------------------------------
    		* Expected a Fixnum (like 1) but got a Float (1533068329.8575015) at $.files[0].foo```
@mefellows mefellows added bug Indicates an unexpected problem or unintended behavior triage labels Jul 31, 2018
@mefellows
Copy link
Member

Ah, I can see the problem. Patch incoming in latest beta...

@mefellows
Copy link
Member

Thanks for the report @alexplischke, this should be fixed in the latest v1.0.0-beta.2.

@alexplischke
Copy link
Author

Thanks for the quick fix!

@mefellows
Copy link
Member

No worries - I'm backporting to the 0.x.x branch also, although I recommend you upgrade to the 1.x.x branch as soon as you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants