32 lines
509 B
Go
32 lines
509 B
Go
|
package message
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
type testmail struct {
|
||
|
Message string
|
||
|
}
|
||
|
|
||
|
func (t testmail) Subject() string {
|
||
|
return "Test Test"
|
||
|
}
|
||
|
|
||
|
func (t testmail) HtmlBody() (string, error) {
|
||
|
content := `<p>{{.Message}}</p>`
|
||
|
return render(layout, content, t)
|
||
|
}
|
||
|
|
||
|
func TestRender(t *testing.T) {
|
||
|
tpl := testmail{
|
||
|
Message: "some mesage",
|
||
|
}
|
||
|
|
||
|
if b, err := tpl.HtmlBody(); err != nil {
|
||
|
t.Error(err)
|
||
|
} else if !strings.Contains(b, tpl.Message) {
|
||
|
t.Error("supposed to contain:", tpl.Message)
|
||
|
}
|
||
|
}
|