-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmailgun_manager_test.go
73 lines (62 loc) · 1.79 KB
/
mailgun_manager_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package email
import (
"os"
"testing"
"github.com/brianvoe/gofakeit/v6"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/adwitiyaio/arka/config"
"github.com/adwitiyaio/arka/dependency"
"github.com/adwitiyaio/arka/secrets"
)
type MailgunManagerTestSuite struct {
suite.Suite
m Manager
}
func TestMailgunManager(t *testing.T) {
suite.Run(t, new(MailgunManagerTestSuite))
}
func (ts *MailgunManagerTestSuite) SetupSuite() {
config.Bootstrap(config.ProviderEnvironment, "../test.env")
secrets.Bootstrap(secrets.ProviderEnvironment, "")
err := os.Setenv("CI", "true")
require.NoError(ts.T(), err)
Bootstrap(ProviderMailgun)
ts.m = dependency.GetManager().Get(DependencyEmailManager).(Manager)
}
func (ts MailgunManagerTestSuite) Test_mailgunManager_SendEmail() {
ts.Run("recipient limit", func() {
var to []string
for i := 0; i <= 1001; i++ {
to = append(to, gofakeit.Email())
}
options := Options{
Sender: gofakeit.Email(),
Subject: "Integration Testing",
Html: "<body>Hello</body>",
Text: "Hello",
To: to,
Cc: []string{gofakeit.Email()},
Bcc: []string{gofakeit.Email()},
}
res, err := ts.m.SendEmail(options)
assert.NoError(ts.T(), err)
assert.Equal(ts.T(), "", res)
})
ts.Run("success", func() {
options := Options{
Sender: gofakeit.Email(),
Subject: "Integration Testing",
Html: "<body>Hello</body>",
Text: "Hello",
To: []string{gofakeit.Email(), gofakeit.Name()},
Cc: []string{gofakeit.Email()},
Bcc: []string{gofakeit.Email()},
Attachments: []string{"./testdata/sample.txt"},
}
res, err := ts.m.SendEmail(options)
assert.NoError(ts.T(), err)
assert.Equal(ts.T(), "", res)
})
}