diff options
Diffstat (limited to 'app/user_test.go')
-rw-r--r-- | app/user_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/user_test.go b/app/user_test.go index ce2249ca0..5b994d219 100644 --- a/app/user_test.go +++ b/app/user_test.go @@ -25,3 +25,29 @@ func TestIsUsernameTaken(t *testing.T) { t.FailNow() } } + +func TestCheckUserDomain(t *testing.T) { + th := Setup().InitBasic() + user := th.BasicUser + + cases := []struct { + domains string + matched bool + }{ + {"simulator.amazonses.com", true}, + {"gmail.com", false}, + {"", true}, + {"gmail.com simulator.amazonses.com", true}, + } + for _, c := range cases { + matched := CheckUserDomain(user, c.domains) + if matched != c.matched { + if c.matched { + t.Logf("'%v' should have matched '%v'", user.Email, c.domains) + } else { + t.Logf("'%v' should not have matched '%v'", user.Email, c.domains) + } + t.FailNow() + } + } +} |