You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
=== RUN TestProductProvider
2023-08-05T14:11:11.107350Z INFO ThreadId(11) pact_verifier: Running setup provider state change handler 'product #1 exists' for 'a request to get product #1'
2023/08/05 21:11:11 [INFO] executing state handler middleware
2023-08-05T14:11:11.287108Z INFO ThreadId(11) pact_verifier: Running provider verification for 'a request to get product #1'
2023-08-05T14:11:11.287166Z INFO ThreadId(11) pact_verifier::provider_client: Sending request to provider at http://localhost:52872/
2023-08-05T14:11:11.287168Z INFO ThreadId(11) pact_verifier::provider_client: Sending request HTTP Request ( method: GET, path: /products/1, query: None, headers: None, body: Missing )
2023-08-05T14:11:11.288802Z INFO ThreadId(11) pact_verifier::provider_client: Received response: HTTP Response ( status: 200, headers: Some({"content-length": ["18"], "content-type": ["application/json"], "date": ["Sat, 05 Aug 2023 14:11:11 GMT"]}), body: Present(18 bytes, application/json) )
2023-08-05T14:11:11.288821Z INFO ThreadId(11) pact_matching: comparing to expected response: HTTP Response ( status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(18 bytes, application/json) )
2023-08-05T14:11:11.290069Z INFO ThreadId(11) pact_verifier: Running teardown provider state change handler 'product #1 exists' for 'a request to get product #1'
2023/08/05 21:11:11 [INFO] executing state handler middleware
Verifying a pact between product-consumer and product-provider
a request to get product #1 (0s loading, 522ms verification)
Given product #1 exists
returns a response which
has status code 200 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (FAILED)
Failures:
1) Verifying a pact between product-consumer and product-provider Given product #1 exists - a request to get product #1
1.1) has a matching body
$.price -> Expected '5' to be a decimal value
There were 1 pact failures
productprovider_test.go:52:
Error Trace: /Users/some.user/path/to/productprovider/productprovider_test.go:52
Error: Received unexpected error:
the verifier failed to successfully verify the pacts, this indicates an issue with the provider API
Test: TestProductProvider
--- FAIL: TestProductProvider (0.58s)
=== RUN TestProductProvider/Provider_pact_verification
verifier.go:184: the verifier failed to successfully verify the pacts, this indicates an issue with the provider API
--- FAIL: TestProductProvider/Provider_pact_verification (0.00s)
FAIL
Process finished with the exit code 1
Relevent log files
N/A
Please note that if I change the dummy value in provider server from 5.0 to 5.1 then the provider verifier test works.
The text was updated successfully, but these errors were encountered:
This is likely a limitation of the JSON parser. It seems somewhere in the chain 5.0 is being reduced to simply 5.
Can you confirm that what is sent over the wire is 5 or 5.0? In JS I know it will be 5 even if a decimal is provided. As such there's not much a test framework can do if it doesn't receive a value with decimal places.
2023/08/06 09:54:38 product is marshalled into {"id":1,"price":5}
It looks like the json marshaller in Go truncates 5.0 to 5, so the behavior is the same as JS. I don't know how to overcome this for now (except writing my own marshaller), maybe just make sure that the provider verifier tests avoiding decimal with only 0 after the decimal point.
Software versions
go env
Expected behaviour
5.0
should be a valid decimal value when running provider verifierActual behaviour
5.0
is not considered a valid decimal value when running provider verifierSteps to reproduce
consumer
and its test.Relevent log files
N/A
Please note that if I change the dummy value in provider server from
5.0
to5.1
then the provider verifier test works.The text was updated successfully, but these errors were encountered: