blob: 15f15a4c84e1deabf4cfeb76790557cdce1f4869 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package app
import (
"strings"
"testing"
)
func TestIsValidUsername(t *testing.T) {
t.Run("long", func(t *testing.T) {
if isValidUsername(strings.Repeat("a", sysconf(_SC_LOGIN_NAME_MAX))) {
t.Errorf("isValidUsername unexpected true")
}
})
t.Run("regexp", func(t *testing.T) {
if isValidUsername("0") {
t.Errorf("isValidUsername unexpected true")
}
})
t.Run("valid", func(t *testing.T) {
if !isValidUsername("alice") {
t.Errorf("isValidUsername unexpected false")
}
})
}
|