Lightweight and easily self-hostable Git forge. git.poy.ooo
git-forge selfhosting homebrew
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243package lib
import ( "strings" "testing")
func TestValidateHandle(t *testing.T) { validHandles := []string{"valid_handle123", "valid-ha_ndle", "139942812", "poyovalidhandle", "123-123-1sad", "aaaaaaaaadsjlaskd"} invalidHandles := []string{"--inva1-lid", "inv--alid", "inv_-_-alid", "123ñ412l(s", "UPPERCA-SED13-", "UPPERCASE", "------", "a", "dddddddddddddddddddddddddddddddddddddddddddddddddddd"}
for i := range validHandles { handle := validHandles[i] if !ValidateHandle(handle) { t.Errorf(`ValidateHandle("%s") FAILED. It returned false. It should return true`, handle) } }
for i := range invalidHandles { handle := invalidHandles[i] if ValidateHandle(handle) { t.Errorf(`ValidateHandle("%s") FAILED. It returned true. It should return false`, handle) } }}
func TestValidateUsername(t *testing.T) { valid := []string{"ab", "poyo", strings.Repeat("a", 40)} invalid := []string{"", "a", strings.Repeat("a", 41)}
for _, name := range valid { if !ValidateUsername(name) { t.Errorf(`ValidateUsername(%q) = false, want true`, name) } }
for _, name := range invalid { if ValidateUsername(name) { t.Errorf(`ValidateUsername(%q) = true, want false`, name) } }}