diff options
| author | Horus3 | 2015-05-17 03:32:03 +0200 |
|---|---|---|
| committer | Horus3 | 2015-05-17 03:32:03 +0200 |
| commit | cc207536d1f8618385d9807906818180cd596777 (patch) | |
| tree | 0093a6b12994c3d75b2be0abb6a43dae1eb9bf98 /handler_test.go | |
| parent | feb97c32649dfaa7c98283423125283a53d5dd09 (diff) | |
| download | freemail-cc207536d1f8618385d9807906818180cd596777.tar.gz | |
Improve tests. Fix (major) typos. Include Piwik and it tracks the language.
Diffstat (limited to 'handler_test.go')
| -rw-r--r-- | handler_test.go | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/handler_test.go b/handler_test.go index 2ea7494..8bbf36a 100644 --- a/handler_test.go +++ b/handler_test.go @@ -4,6 +4,7 @@ import ( "net/http" "net/http/httptest" "net/url" + "os" "strings" "testing" ) @@ -92,10 +93,15 @@ func BenchmarkRegisterHandler(b *testing.B) { } func TestCreateNewEntryHandler(t *testing.T) { + if testing.Short() || !*testExternal { + t.Skip("Skipping test to avoid external network.") + } + + domain := os.Getenv("FREEMAIL_SMTP_MAILER_MX") form := url.Values{} - form.Set("Email", "createNewEntry@localhost") - form.Set("ConfirmEmail", "createNewEntry@localhost") + form.Set("Email", "createNewEntry@"+domain) + form.Set("ConfirmEmail", "createNewEntry@"+domain) form.Set("Password", "Password") form.Set("ConfirmPassword", "Password") @@ -342,15 +348,20 @@ func BenchmarkPasswordHandler(b *testing.B) { func TestChangePasswordHandler(t *testing.T) { + if testing.Short() || !*testExternal { + t.Skip("Skipping test to avoid external network.") + } + // Test with the correct form form := url.Values{} - if err := CreateNewEntry("test@localhost", Md5Hash("Password")); err != nil { + domain := os.Getenv("FREEMAIL_SMTP_MAILER_MX") + if err := CreateNewEntry("test@"+domain, Md5Hash("Password")); err != nil { t.Fatal(err) } - form.Set("Email", "test@localhost") + form.Set("Email", "test@"+domain) form.Set("Password", "Password") form.Set("ConfirmPassword", "password") form.Set("NewPassword", "password") @@ -395,11 +406,11 @@ func TestChangePasswordHandler(t *testing.T) { form = url.Values{} - if err = CreateNewEntry("test1@localhost", Md5Hash("Password")); err != nil { + if err = CreateNewEntry("test1@"+domain, Md5Hash("Password")); err != nil { t.Fatal(err) } - form.Set("Email", "test1@localhost") + form.Set("Email", "test1@"+domain) form.Set("Password", "Password") form.Set("ConfirmPassword", "Password") form.Set("NewPassword", "password") @@ -439,11 +450,11 @@ func TestChangePasswordHandler(t *testing.T) { form = url.Values{} - if err = CreateNewEntry("test2@localhost", Md5Hash("Password")); err != nil { + if err = CreateNewEntry("test2@"+domain, Md5Hash("Password")); err != nil { t.Fatal(err) } - form.Set("Email", "test2@localhost") + form.Set("Email", "test2@"+domain) form.Set("Password", "password") form.Set("ConfirmPassword", "Password") form.Set("NewPassword", "Password") @@ -483,7 +494,7 @@ func TestChangePasswordHandler(t *testing.T) { form = url.Values{} - form.Set("Email", "nonexistent@localhost") + form.Set("Email", "nonexistent@"+domain) form.Set("Password", "password") form.Set("ConfirmPassword", "Password") form.Set("NewPassword", "Password") |
