Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit 7f6d24c

Browse files
committed
fixed SendMail test hardcoded to use AWS
1 parent 67560ac commit 7f6d24c

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

main_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/staticbackendhq/core/cache"
1414
"github.com/staticbackendhq/core/database/mongo"
1515
"github.com/staticbackendhq/core/database/postgresql"
16+
"github.com/staticbackendhq/core/email"
1617
"github.com/staticbackendhq/core/internal"
1718
)
1819

@@ -56,6 +57,13 @@ func TestMain(m *testing.M) {
5657

5758
database = &Database{cache: volatile}
5859

60+
mp := os.Getenv("MAIL_PROVIDER")
61+
if strings.EqualFold(mp, internal.MailProviderSES) {
62+
emailer = email.AWSSES{}
63+
} else {
64+
emailer = email.Dev{}
65+
}
66+
5967
deleteAndSetupTestAccount()
6068

6169
hub := newHub(volatile)

sendmail_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
package staticbackend
22

33
import (
4+
"os"
45
"testing"
56

6-
"github.com/staticbackendhq/core/email"
77
"github.com/staticbackendhq/core/internal"
88
)
99

10-
func Test_Sendmail_AWS(t *testing.T) {
11-
emailer := &email.AWSSES{}
12-
10+
func Test_Sendmail(t *testing.T) {
1311
data := internal.SendMailData{
14-
FromName: "My name here",
15-
16-
12+
FromName: os.Getenv("FROM_NAME"),
13+
From: os.Getenv("FROM_EMAIL"),
14+
To: "dominicstpierre+unittest@gmail.com",
1715
ToName: "Dominic St-Pierre",
1816
Subject: "From unit test",
1917
HTMLBody: "<h1>hello</h1><p>working</p>",
2018
TextBody: "Hello\nworking",
21-
ReplyTo: "[email protected]",
19+
ReplyTo: os.Getenv("FROM_EMAIL"),
2220
}
2321
if err := emailer.Send(data); err != nil {
2422
t.Error(err)

0 commit comments

Comments
 (0)