forked from volatiletech/authboss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
response_test.go
43 lines (33 loc) · 717 Bytes
/
response_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package authboss
import (
"context"
"testing"
)
type testMailer struct{ sent bool }
func (t *testMailer) Send(context.Context, Email) error {
t.sent = true
return nil
}
func TestEmail(t *testing.T) {
t.Parallel()
ab := New()
mailer := &testMailer{}
renderer := &mockEmailRenderer{}
ab.Config.Core.Mailer = mailer
ab.Config.Core.MailRenderer = renderer
email := Email{
To: []string{"[email protected]"},
Subject: "Send help",
}
ro := EmailResponseOptions{
Data: nil,
HTMLTemplate: "html",
TextTemplate: "text",
}
if err := ab.Email(context.Background(), email, ro); err != nil {
t.Error(err)
}
if !mailer.sent {
t.Error("the e-mail should have been sent")
}
}