From 274686d10d3386a41f8fb6bc3363269a734afe0e Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 29 Oct 2025 03:40:09 +0900 Subject: 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 --- internal/validate/username_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 internal/validate/username_test.go (limited to 'internal/validate/username_test.go') 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") + } + }) +} -- cgit v1.3.1