diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-08-28 08:37:55 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-08-28 08:37:55 -0400 |
commit | f5fec3a157e6c9146a0c4e28dd5f70e6c066affd (patch) | |
tree | 176afd630a3afbe0ac3389695be6b4ce1c45d069 /model/user_test.go | |
parent | db7e8c12889485234fb2d1ba6556106e5fc7548b (diff) | |
download | chat-f5fec3a157e6c9146a0c4e28dd5f70e6c066affd.tar.gz chat-f5fec3a157e6c9146a0c4e28dd5f70e6c066affd.tar.bz2 chat-f5fec3a157e6c9146a0c4e28dd5f70e6c066affd.zip |
Added the ability to create a team with SSO services and added the ability to turn off email sign up.
Diffstat (limited to 'model/user_test.go')
-rw-r--r-- | model/user_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
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") + } +} |