stephenafamo / bob

SQL query builder and ORM/Factory generator for Go with support for PostgreSQL, MySQL and SQLite
https://bob.stephenafamo.com
MIT License
701 stars 37 forks source link

Flaky test #235

Closed pcriv closed 2 days ago

pcriv commented 3 weeks ago

From time to time I get this test failure, seems to be a flaky one

=== Failed
=== FAIL: internal/dbgen/factory TestRandom_uint8 (0.00s)
    bobfactory_random_test.go:135: random[uint8]() returned the same value twice: 59
stephenafamo commented 2 weeks ago

The reason for this is that uint8 has 256 possible values.

To test randomization, we generate 10 values and make sure the same value does not repeat. With 256 possible values, if my math is correct, there's a 16.3% chance that a duplicate will be generated.

To keep things simple, I'm going to make it 2 values, this should reduce the chance of duplicates to 0.4% and 2 values should be enough to test if duplicates are generated correctly.

stephenafamo commented 2 days ago

This should have been fixed in v0.28.0 which was released on 2024-06-25