aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/validate/username_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-29 03:40:09 +0900
committerOphestra <cat@gensokyo.uk>2025-10-29 03:40:09 +0900
commit274686d10d3386a41f8fb6bc3363269a734afe0e (patch)
tree59ce81d5617cf5e1f67b819dab49b83b71d8ff93 /internal/validate/username_test.go
parent65342d588ff061d2130e6379d86a26be90c908ae (diff)
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>
Diffstat (limited to 'internal/validate/username_test.go')
-rw-r--r--internal/validate/username_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/validate/username_test.go b/internal/validate/username_test.go
new file mode 100644
index 00000000..1970fa4a
--- /dev/null
+++ b/internal/validate/username_test.go
@@ -0,0 +1,30 @@
+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")
+ }
+ })
+}