Files
gotenberg/internal/pkg/xrand/xrand_test.go
Julien Neuhart 7bfbda4490 huge refactoring
2019-07-23 13:57:18 +02:00

29 lines
527 B
Go

package xrand
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())
}