forked from sendgrid/sendgrid-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twilio_email_test.go
34 lines (29 loc) · 945 Bytes
/
twilio_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
package sendgrid
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewTwilioEmailSendClient(t *testing.T) {
mailClient := NewTwilioEmailSendClient("username", "password")
assert.Equal(t, "https://email.twilio.com/v3/mail/send", mailClient.BaseURL)
assert.Equal(t, "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", mailClient.Headers["Authorization"])
}
func TestGetTwilioEmailRequest(t *testing.T) {
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintln(w, "{\"message\": \"success\"}")
}))
defer fakeServer.Close()
request := GetTwilioEmailRequest(TwilioEmailOptions{
Username: "username",
Password: "password",
Host: fakeServer.URL,
})
response, err := MakeRequest(request)
require.NoError(t, err)
assert.True(t, strings.Contains(response.Body, "success"))
}