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

Sort the list of words to prevent empty Text() result #95

Closed tony2001 closed 2 years ago

tony2001 commented 2 years ago

At the moment Lorem().Text(N) returns empty string for N < 5. This is kinda expected from the code - the first word in the list is "alias", which is 5 symbols long, but there are shorter words in the list, so this looks like a bug to me. Let's just sort the list of words by their length, I believe this should not affect anything, at least it passes all the tests alright. I went ahead, sorted the list and added a tests to make sure that Text(N) never returns an empty string for N > 0.

codecov[bot] commented 2 years ago

Codecov Report

Merging #95 (773fb6a) into master (62506c3) will decrease coverage by 0.82%. The diff coverage is n/a.

@@            Coverage Diff             @@
##           master      #95      +/-   ##
==========================================
- Coverage   96.49%   95.66%   -0.83%     
==========================================
  Files          36       36              
  Lines        1085     1085              
==========================================
- Hits         1047     1038       -9     
- Misses         30       41      +11     
+ Partials        8        6       -2     
Impacted Files Coverage Δ
lorem.go 100.00% <ø> (ø)
internet.go 92.92% <0.00%> (-4.43%) :arrow_down:
person.go 92.59% <0.00%> (-3.71%) :arrow_down:
faker.go 88.93% <0.00%> (-1.59%) :arrow_down:
crypto.go 94.23% <0.00%> (ø)
phone.go 100.00% <0.00%> (+7.14%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 62506c3...773fb6a. Read the comment docs.

jaswdr commented 2 years ago

LGTM, thank you and congrats for your first PR! 🎆 😄

jaswdr commented 2 years ago

Changes released in v1.11.1