-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
Matching a number causes expected type vs actual type mismatch #94
Comments
I think there was a related issue about numbers and floats specifically for JavaScript. |
Thanks for your reply can u see any issues with what my expectation is
I get [{"gross_income":{"EXPECTED_TYPE":"Fixnum","ACTUAL_TYPE":"Float"}}]} |
@louisandkatherine see #77 |
^^^ Use |
Thanks for your quick reply on this! Is there no way we could not pass the type i.e. Number (accepts either), Float (accepts only floats), FixNum (accepts only integer) ? As an enhancement? What would be wrong about this? Our requirement is that we may indeed send in the same field to an api a figure which could be an integer or a float depending on a user's income. |
In that case, make one interaction with a float, and one with an integer.
…On 12 Sep. 2017 10:33 pm, "louisandkatherine" ***@***.***> wrote:
Thanks for your quick reply on this!
Is there no way we could not pass the type i.e. Number (accepts either),
Float (accepts only floats), FixNum (accepts only integer) ? As an
enhancement? What would be wrong about this?
Our requirement is that we may indeed send in the same field to an api a
figure which could be an integer or a float depending on a user's income.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#94 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAbPFD_rj4g6F4h1i5deuEzKNIHnOOu3ks5shnoxgaJpZM4PTDX4>
.
|
What would be wrong is that one example specifying "float or integer" could pass 100 of the time, and still only allow one of the two types, and you can't tell from that specification which one. You need to exercise both paths separately to be sure that both are accepted. You're not specifying a schema here, you're specifying a test case. |
Thanks for your reply again on this! I will try with this, although some of our services return dynamic data, changing on the day etc, therefore matchers for numbers + floats etc are very useful |
Sorry to bump a year old post 🙈
provider response returns multiple objects with float and interger
Consumer pact looks like
In this case how can we creat different interactions for float and Int as the response from provider will have both float and Interger Can you please help on this? |
I'm confused about your issue. As you saying the value of "value" may be either a float or an integer? |
yes |
You would explictly need to write two separate test cases. One that only replies with floats from the provider, and another for integers in those same fields.
test case for floats:
|
So when the consumer shares the contract with GET /validPrices this endpoint from provider would respond floats for few fields and Integer for few fields. R u saying the provider should respond only float and Integer based on an endpoint. Sorry, I'm quite not getting. |
We're experiencing a similar issue with a field, but this issue is compounded by the field containing null values for some records (upstream legacy which we cannot enrich).. This in effect means we require a PACT test to pass whether we have Doing as suggested, would mean faking / corralling a lot of unrealistic test data across 3 separate tests. This feels very undesirable and unrealistic to a real world API test case where records would be mixed. I believe a |
If we were to take that matcher on board, it would have to come with a lot of warnings because the very nature of a Currently, as is stated above and in our docs, we have a very strict policy with matching fields. On the other hand, it is a common challenge and I wonder if there is another way we can help with it. |
This is an explanation of why we don't currently have a "LikeAny" https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes |
Hi there,
Really love this library! however I'm getting an issue around matching on a number. When I use
somethingLike(50000) but my service sends or actually returns a float I get this error
{"gross_income":{"EXPECTED_TYPE":"Fixnum","ACTUAL_TYPE":"Float"}}]}
Is there a workaround for this?
Many thanks
Louis
The text was updated successfully, but these errors were encountered: