From f5fec3a157e6c9146a0c4e28dd5f70e6c066affd Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 28 Aug 2015 08:37:55 -0400 Subject: Added the ability to create a team with SSO services and added the ability to turn off email sign up. --- model/user_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'model/user_test.go') diff --git a/model/user_test.go b/model/user_test.go index a48c3f2e7..a3b4be091 100644 --- a/model/user_test.go +++ b/model/user_test.go @@ -150,3 +150,45 @@ func TestUserGetDisplayName(t *testing.T) { t.Fatal("Display name should be nickname") } } + +var usernames = []struct { + value string + expected bool +}{ + {"spin-punch", true}, + {"Spin-punch", false}, + {"spin punch-", false}, + {"spin_punch", true}, + {"spin", true}, + {"PUNCH", false}, + {"spin.punch", true}, + {"spin'punch", false}, + {"spin*punch", false}, + {"all", false}, +} + +func TestValidUsername(t *testing.T) { + for _, v := range usernames { + if IsValidUsername(v.value) != v.expected { + t.Errorf("expect %v as %v", v.value, v.expected) + } + } +} + +func TestCleanUsername(t *testing.T) { + if CleanUsername("Spin-punch") != "spin-punch" { + t.Fatal("didn't clean name properly") + } + if CleanUsername("PUNCH") != "punch" { + t.Fatal("didn't clean name properly") + } + if CleanUsername("spin'punch") != "spin-punch" { + t.Fatal("didn't clean name properly") + } + if CleanUsername("spin") != "spin" { + t.Fatal("didn't clean name properly") + } + if len(CleanUsername("all")) != 27 { + t.Fatal("didn't clean name properly") + } +} -- cgit v1.2.3-1-g7c22