19 lines
322 B
Go
19 lines
322 B
Go
|
|
package model
|
||
|
|
|
||
|
|
import (
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestGenerateRandomPassword(t *testing.T) {
|
||
|
|
pwd := GenerateRandomPassword(16)
|
||
|
|
if len(pwd) != 16 {
|
||
|
|
t.Fatalf("length mismatch: %d", len(pwd))
|
||
|
|
}
|
||
|
|
for _, ch := range pwd {
|
||
|
|
if !strings.ContainsRune(passwordChars, ch) {
|
||
|
|
t.Fatalf("unexpected char: %c", ch)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|