diff options
Diffstat (limited to 'email_test.go')
| -rw-r--r-- | email_test.go | 37 |
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.") + } +} |
