Fix race condition

This commit is contained in:
Deluan
2024-07-22 14:27:02 -04:00
parent 9b4abd9e5a
commit d046c180bf
2 changed files with 20 additions and 4 deletions
+11
View File
@@ -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())
}()
}
})
})