-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_test.go
68 lines (57 loc) · 1.84 KB
/
email_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
package sendios
import (
"github.com/joho/godotenv"
"github.com/stretchr/testify/require"
"os"
"strconv"
"testing"
)
func TestSendEmail(t *testing.T) {
require.NoError(t, godotenv.Load())
require.NotEmpty(t, os.Getenv("SENDIOS_PROJECT"))
require.NotEmpty(t, os.Getenv("SENDIOS_CLIENT_ID"))
require.NotEmpty(t, os.Getenv("SENDIOS_TOKEN"))
require.NotEmpty(t, os.Getenv("TEST_EMAIL"))
project, err := strconv.Atoi(os.Getenv("SENDIOS_PROJECT"))
require.NoError(t, err)
client, err := strconv.Atoi(os.Getenv("SENDIOS_CLIENT_ID"))
require.NoError(t, err)
c := New(project, client, os.Getenv("SENDIOS_TOKEN"))
c.DebugRequests = true
result, err := c.SendEmail(EmailRequest{
TypeID: 11,
Category: CategorySystem,
Data: map[string]interface{}{
"redirect_url": "https://localhost:3000",
"user": map[string]interface{}{
"email": "igor.chornij@gen.tech",
"name": "Igor",
},
},
})
require.NoError(t, err)
require.Equal(t, "SUCCESS", result.Meta.Status)
}
func TestSendEmailWithError(t *testing.T) {
require.NoError(t, godotenv.Load())
require.NotEmpty(t, os.Getenv("SENDIOS_PROJECT"))
require.NotEmpty(t, os.Getenv("SENDIOS_CLIENT_ID"))
require.NotEmpty(t, os.Getenv("SENDIOS_TOKEN"))
require.NotEmpty(t, os.Getenv("TEST_EMAIL"))
project, err := strconv.Atoi(os.Getenv("SENDIOS_PROJECT"))
require.NoError(t, err)
client, err := strconv.Atoi(os.Getenv("SENDIOS_CLIENT_ID"))
require.NoError(t, err)
c := New(project, client, os.Getenv("SENDIOS_TOKEN"))
c.DebugRequests = true
result, err := c.SendEmail(EmailRequest{
TypeID: 11,
Category: CategorySystem,
Data: map[string]interface{}{
"redirect_url": "https://localhost:3000",
},
})
require.Error(t, err)
require.Equal(t, "Request validation error: data - This value should contain key `user`", err.Error())
require.Equal(t, "ERROR", result.Meta.Status)
}