datafaker-net / datafaker

Generating fake data for the JVM (Java, Kotlin, Groovy) has never been easier!
https://www.datafaker.net
Apache License 2.0
1.09k stars 151 forks source link

fix: Aviation Test #1241

Closed kingthorin closed 1 month ago

kingthorin commented 1 month ago

Following the failure here: https://github.com/datafaker-net/datafaker/actions/runs/9324424830/job/25669623466#step:4:1

Which apparently only had a 1 in 4037 chance of happening on any given test run, lucky us :grinning:

I threw together this temporary test (I'm sure there are more elegant ways to do this, it was just a quick thing):

@Test
void checkLengths() {
    List<String> entries = getBaseList("aviation.airport");
    System.out.println(entries.size());
    Map<Integer, Integer> lenMap = new HashMap<>();
    lenMap.put(1, 0);
    lenMap.put(2, 0);
    lenMap.put(3, 0);
    lenMap.put(4, 0);
    lenMap.put(5, 0);
    lenMap.put(6, 0);
    for (String entry : entries) {
        Integer count = lenMap.get(entry.length());
        count++;
        lenMap.put(entry.length(), count);
        if (entry.length() != 4) {
            System.out.println(entry);
        }
    }
    System.out.println(lenMap);
}

Which produced:

4037
N55
{1=0, 2=0, 3=1, 4=4036, 5=0, 6=0}

Indeed N55 is a valid airport: https://www.google.com/search?q=N55+airport - Jaluit Airport

So I've adjusted the regex in the test to allow length 3 or 4.

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.03%. Comparing base (b37c566) to head (ad08e81). Report is 144 commits behind head on main.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1241 +/- ## ============================================ - Coverage 92.35% 92.03% -0.32% - Complexity 2821 3042 +221 ============================================ Files 292 309 +17 Lines 5609 5987 +378 Branches 599 629 +30 ============================================ + Hits 5180 5510 +330 - Misses 275 319 +44 - Partials 154 158 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.