summaryrefslogtreecommitdiffstats
path: root/model/user_test.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-02-05 14:56:01 -0500
committerGitHub <noreply@github.com>2018-02-05 14:56:01 -0500
commitd5d1834c041d5c676a556965dc98299eef750c9c (patch)
tree9af061953f2fcf47338995c9d6d627364d1d27ea /model/user_test.go
parentaaccb1226e6051829c295ad192ed89a00dbd4c98 (diff)
downloadchat-d5d1834c041d5c676a556965dc98299eef750c9c.tar.gz
chat-d5d1834c041d5c676a556965dc98299eef750c9c.tar.bz2
chat-d5d1834c041d5c676a556965dc98299eef750c9c.zip
ABC-173: introduce Normalize(Username|Email) (#8183)
This centralizes the source of truth on the rules for username / email processing instead of scattering `strings.ToLower` invocations.
Diffstat (limited to 'model/user_test.go')
-rw-r--r--model/user_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/model/user_test.go b/model/user_test.go
index c91051532..2bf8b2a65 100644
--- a/model/user_test.go
+++ b/model/user_test.go
@@ -243,6 +243,30 @@ func TestValidUsername(t *testing.T) {
}
}
+func TestNormalizeUsername(t *testing.T) {
+ if NormalizeUsername("Spin-punch") != "spin-punch" {
+ t.Fatal("didn't normalize username properly")
+ }
+ if NormalizeUsername("PUNCH") != "punch" {
+ t.Fatal("didn't normalize username properly")
+ }
+ if NormalizeUsername("spin") != "spin" {
+ t.Fatal("didn't normalize username properly")
+ }
+}
+
+func TestNormalizeEmail(t *testing.T) {
+ if NormalizeEmail("TEST@EXAMPLE.COM") != "test@example.com" {
+ t.Fatal("didn't normalize email properly")
+ }
+ if NormalizeEmail("TEST2@example.com") != "test2@example.com" {
+ t.Fatal("didn't normalize email properly")
+ }
+ if NormalizeEmail("test3@example.com") != "test3@example.com" {
+ t.Fatal("didn't normalize email properly")
+ }
+}
+
func TestCleanUsername(t *testing.T) {
if CleanUsername("Spin-punch") != "spin-punch" {
t.Fatal("didn't clean name properly")