adding tests for random pkg

This commit is contained in:
Julien Neuhart
2019-07-08 18:06:43 +02:00
parent 9c6f23d7cc
commit 9ab8d03697
2 changed files with 31 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
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 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())
}