From f334c93c0364d14a2b55641b155ad58f715a4b39 Mon Sep 17 00:00:00 2001 From: horus_arch Date: Thu, 19 Mar 2015 13:39:37 +0100 Subject: Rewriting from scratch. --- email_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 email_test.go (limited to 'email_test.go') 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.") + } +} -- cgit v1.2.3