Files
gotenberg/internal/pkg/random/random_test.go
2019-07-08 18:07:44 +02:00

29 lines
528 B
Go

package random
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGet(t *testing.T) {
var rands []string
// use case: for 1 000 concurrent
// requests (which is a big Gotenberg instance),
// none should have the same identifier.
for i := 0; i < 1000; i++ {
rands = append(rands, Get())
}
unique := func() bool {
for i, rand := range rands {
for j, current := range rands {
if i != j && rand == current {
return false
}
}
}
return true
}
assert.Equal(t, true, unique())
}