hakurei/internal/validate/username_test.go
Ophestra 274686d10d
All checks were successful
Test / Create distribution (push) Successful in 37s
Test / Sandbox (push) Successful in 2m23s
Test / Hakurei (push) Successful in 3m9s
Test / Hpkg (push) Successful in 4m7s
Test / Sandbox (race detector) (push) Successful in 4m11s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Successful in 1m30s
internal/validate: relocate from app
These are free of the dispatcher from internal/app. This change relocates them into their own package.

Signed-off-by: Ophestra <cat@gensokyo.uk>
2025-10-29 03:40:09 +09:00

31 lines
606 B
Go

package validate_test
import (
"strings"
"testing"
"hakurei.app/internal/validate"
)
func TestIsValidUsername(t *testing.T) {
t.Parallel()
t.Run("long", func(t *testing.T) {
if validate.IsValidUsername(strings.Repeat("a", validate.Sysconf(validate.SC_LOGIN_NAME_MAX))) {
t.Errorf("IsValidUsername unexpected true")
}
})
t.Run("regexp", func(t *testing.T) {
if validate.IsValidUsername("0") {
t.Errorf("IsValidUsername unexpected true")
}
})
t.Run("valid", func(t *testing.T) {
if !validate.IsValidUsername("alice") {
t.Errorf("IsValidUsername unexpected false")
}
})
}