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

fix: Fallback to always generate a value to fix 'Could not generate a random TYPE from null' #335

Conversation

tienvx
Copy link
Contributor

@tienvx tienvx commented Nov 3, 2023

Remove the errors similar to Could not generate a random decimal from null.

It then allow to use integration json like this:

{
    "pact:matcher:type": "null",
    "pact:generator:type": "RandomDecimal"
}

This change is for implementing compatibility suite in pact-php (and probably other languages that use FFI calls as well).

For more information, please take a look at this discussion

@rholshausen
Copy link
Contributor

While this fixes the issue above, it regresses behavior of the random integer and decimal generators.

What the previous code was doing was generating either a number or a string depending on the type of the value. With this change, it will always now generate a string value.

For instant, with input JSON:

{
  "value": 100
}

It will now generate:

{
  "value": "3498499"
}

and not

{
  "value": 3498499
}

I think the fix is to only change the fallback to generate either type of value.

@tienvx tienvx changed the title feat: Force generators works regardless of value's type fix: Fallback to always generate a value to fix 'Could not generate a random TYPE from null' Nov 8, 2023
@tienvx
Copy link
Contributor Author

tienvx commented Nov 8, 2023

I updated the code follow your suggestion

@rholshausen
Copy link
Contributor

Nice!

@rholshausen rholshausen merged commit 32cfd51 into pact-foundation:master Nov 8, 2023
15 checks passed
@tienvx tienvx deleted the force-generator-works-regardless-value-type branch November 8, 2023 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants