mirror of https://github.com/sirupsen/logrus.git
hooks/test: fix incorrect use of math/rand
Fix incorrect uses of math/rand: - do not call rand.Seed() in a test as it affects the global pseudo-random number generator and might affect other tests (or Logrus itself). Instead, use a local instance of a number generator - seed with time.Now().UnixNano() instead of time.Now().Unix() for more randomness - use "rand.Intn(100)" instead of "rand.Int() % 100"
This commit is contained in:
parent
dd1b4c2e81
commit
857f9242a1
|
@ -41,8 +41,8 @@ func TestAllHooks(t *testing.T) {
|
|||
|
||||
func TestLoggingWithHooksRace(t *testing.T) {
|
||||
|
||||
rand.Seed(time.Now().Unix())
|
||||
unlocker := rand.Int() % 100
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
unlocker := r.Intn(100)
|
||||
|
||||
assert := assert.New(t)
|
||||
logger, hook := NewNullLogger()
|
||||
|
|
Loading…
Reference in New Issue