Fixing the CI failure by fixing the infinite loop in Commerce #1971
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems that current faker master is broken https://travis-ci.org/github/faker-ruby/faker/builds since 7034961.
What's happening here is that the ko locale data provides only one
commerce.department
entry where some tests e.g.faker/test/faker/default/test_faker_commerce.rb
Line 31 in d9b9ad9
commerce.department
entries to exist, and because this loop never ends until it successfully fetches the given number of categories, it results in an infinite loop.This is rather a code bug than a data inadequacy. No code should cause such an infinite loop regardless of given data.
This patch firstly extends the existing
sample
method to take an argument in the same manner as Ruby'sArray#sample
.Then now we can simplify the code by using this new
sample
with number instead of fetching multiple times inside the loop.