jaswdr / faker

:rocket: Ultimate fake data generator for Go with zero dependencies
https://pkg.go.dev/github.com/jaswdr/faker
MIT License
566 stars 59 forks source link

[FEATURE] Generator should be wrapped by a Interface to allow mocking #92

Closed xlanor closed 2 years ago

xlanor commented 2 years ago

Is your feature request related to a problem? Please describe. Currently, the generator utilises random.randInt.

This becomes a problem further down the line, for example, when randoming a number between 0-2 to decide a choice of what to return in functions with a wider scope.

Describe the solution you'd like Instead of directly utilising rand, we can use an interface that exposes the methods that we want to use from rand. This allows for the replacement of rand with a mock during unit tests,

xlanor commented 2 years ago

@jaswdr just noticed this PR still open, any thoughts about this?

jaswdr commented 2 years ago

Hello @xlanor, thank you very much for the contribution, I merged and released it in v1.12.0