-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using post instead of get, added test
- Loading branch information
Patrick Crosby
committed
Jan 4, 2013
1 parent
3dd82b4
commit e35c9ff
Showing
2 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package amzses | ||
|
||
import ( | ||
"flag" | ||
"testing" | ||
) | ||
|
||
var to, from string | ||
|
||
func init() { | ||
flag.StringVar(&to, "to", "", "email recipient") | ||
flag.StringVar(&from, "from", "", "email sender") | ||
} | ||
|
||
func checkFlags(t *testing.T) { | ||
if len(to) == 0 { | ||
t.Fatal("must specify recipient via -to flag.") | ||
} | ||
if len(from) == 0 { | ||
t.Fatal("must specify sender via -from flag.") | ||
} | ||
} | ||
|
||
func TestText(t *testing.T) { | ||
checkFlags(t) | ||
_, err := SendMail(from, to, "amzses text test", textBody) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestHtml(t *testing.T) { | ||
checkFlags(t) | ||
_, err := SendMailHTML(from, to, "amzses html test", textBody, htmlBody) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
var textBody = `This is an example email body for the amzses go package.` | ||
|
||
var htmlBody = ` | ||
This is an <b>html email</b>. | ||
<br/> | ||
<br/> | ||
<img src="http://placehold.it/600x200/"> | ||
` |