summaryrefslogtreecommitdiff
path: root/email_test.go
diff options
context:
space:
mode:
authorhorus_arch2015-03-19 13:39:37 +0100
committerhorus_arch2015-03-19 13:39:37 +0100
commitf334c93c0364d14a2b55641b155ad58f715a4b39 (patch)
tree63ffbfc845f441802bd59c07adf2d9fe2f86c4bc /email_test.go
parent3c9bdbc66998075278f7d79fa10709e7fab5deb6 (diff)
downloadfreemail-f334c93c0364d14a2b55641b155ad58f715a4b39.tar.gz
Rewriting from scratch.
Diffstat (limited to 'email_test.go')
-rw-r--r--email_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/email_test.go b/email_test.go
new file mode 100644
index 0000000..887eb8d
--- /dev/null
+++ b/email_test.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "os"
+ "testing"
+)
+
+func TestCreateEmail(t *testing.T) {
+ InitDB()
+ t.Log("Using database: " + os.Getenv("FREEMAIL_DB_CREDENTIALS"))
+ if success, err := CreateEmail("test@example.com", "password"); err != nil || !success {
+ t.Fatal("Can't create email.", err)
+ } else {
+ t.Log("test@example.com")
+ }
+}
+func TestEmailExists(t *testing.T) {
+ t.Log("Using database: " + os.Getenv("FREEMAIL_DB_CREDENTIALS"))
+ vU := VirtualUser{}
+ vU.Email = "test@example.com"
+ /*
+ vU := VirtualUser{}
+ vU.Email = "test@example.com"
+ //if err := Db.Save(&vU); err != nil {
+ if !Db.NewRecord(&vU) {
+ //t.Fatal("Saving record to database failed.", err)
+ t.Fatal("Saving record to database failed.")
+ }
+ */
+ if !EmailExists(vU.Email) {
+ t.Log(EmailExists(vU.Email))
+ t.Fatal("Email should exist. Expected bool true.")
+ }
+ if EmailExists("foo@example.com") {
+ t.Fatal("Email doesn't exist. Expected bool false.")
+ }
+}