Files
upstream-traggo/auth/rand/random_test.go
upstream-mirror cda7c1a474
Some checks failed
build / build (push) Failing after 3s
snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 05:24:45 +05:00

31 lines
500 B
Go

package rand
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestToken(t *testing.T) {
for i := 1; i < 10; i++ {
assert.Len(t, Token(i), i)
}
assert.Len(t, Token(120), 120)
assert.Len(t, Token(222), 222)
assert.Len(t, Token(555665), 555665)
}
func TestToken_panics(t *testing.T) {
old := randRead
defer func() {
randRead = old
}()
randRead = func(b []byte) (n int, err error) {
return 0, errors.New("oops")
}
assert.Panics(t, func() {
Token(1)
})
}