jaswdr / faker

:rocket: Ultimate fake data generator for Go with zero dependencies

Home Page:https://pkg.go.dev/github.com/jaswdr/faker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

xlanor opened this issue · comments

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,

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

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