Fix race condition
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package hasher_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/navidrome/navidrome/utils/hasher"
|
||||
@@ -54,4 +55,14 @@ var _ = Describe("HashFunc", func() {
|
||||
hasher.SetSeed(id, "original_seed")
|
||||
Expect(sum).To(Equal(hashFunc(id, input)))
|
||||
})
|
||||
|
||||
It("does not cause race conditions", func() {
|
||||
for i := 0; i < 1000; i++ {
|
||||
go func() {
|
||||
hashFunc := hasher.HashFunc()
|
||||
sum := hashFunc(strconv.Itoa(i), input)
|
||||
Expect(sum).ToNot(BeZero())
|
||||
}()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user