github.com/rjgonzale/pop/v5@v5.1.3-dev/internal/randx/string_test.go (about) 1 package randx 2 3 import ( 4 "math/rand" 5 "sync" 6 "testing" 7 8 "github.com/stretchr/testify/require" 9 ) 10 11 func init() { 12 rand.Seed(1) 13 } 14 15 func Test_String(t *testing.T) { 16 r := require.New(t) 17 r.Len(String(5), 5) 18 r.Len(String(50), 50) 19 } 20 21 func Test_String_Parallel(t *testing.T) { 22 wg := sync.WaitGroup{} 23 wg.Add(100) 24 for i := 0; i < 100; i++ { 25 go func() { 26 id := String(30) 27 if len(id) != 30 { 28 t.FailNow() 29 } 30 wg.Done() 31 }() 32 } 33 wg.Wait() 34 }