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

Adds support for locale hash #14

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jerui1
Copy link

@jerui1 jerui1 commented May 2, 2024

Please, review this PR after #13

Refactors RandomHelper a little bit.

Creates and use a default OR seeded OR localized OR seededAndLocalized faker, according to given hash.

Adds a Random field to make unit testing easier. (Especially for localizedNonSeeded faker)
Adds a package private constructor for tests.

References

Allow users to specify the locale for fake data #2

Submitter checklist

  • Recommended: Join WireMock Slack to get any help in #help-contributing or a project-specific channel like #wiremock-java
  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

@jerui1 jerui1 changed the title Feature/allow users to specify the locale for fake data Adds support for locale hash May 2, 2024
@jimcornmell
Copy link

Hi This does not seem to work for me, I've probably screwed up, appologies if I have.

I've done the following:

git clone [email protected]:jerui1/wiremock-faker-extension.git
cd wiremock-faker-extension
gradle build

Added to wiremock, started it and used all the locale variations I can think of:

{{ random 'Address.postcode' seed=1234 locale='en_GB' }}
{{ random 'Address.postcode' seed=1234 locale='en-GB' }}
{{ random 'Address.postcode' seed=1234 locale='GB' }}
{{ random 'Address.postcode' seed=1234 locale='gb' }}
{{ random 'Address.postcode' seed=1234 locale='en' }}

All come back with postcodes which are american format, i.e. 5 digits. I'd expect UK format postcodes, i.e. something like XX12 3XX.

As an example I've used the python standalone faker in scripts and that works something like this, although I can only vouch for the UK postcodes looking authentic:

 $  export LANG=da_DK 
 $  faker -r 3 postcode
8014
7650
5035

 $  export LANG=fr_FR
 $  faker -r 3 postcode
13369
27633
67840

 $  export LANG=ru_RU 
 $  faker -r 3 postcode
280896
469642
566794

 $  export LANG=en_GB 
 $  faker -r 3 postcode
E9 3FY
DE18 7TB
CH3 3ZG

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.

3 participants