forked from resend/resend-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch_test.go
46 lines (40 loc) · 855 Bytes
/
batch_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
package resend
import (
"encoding/json"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBatchSendEmail(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/emails/batch", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPost)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
ret := &BatchEmailResponse{
Data: []SendEmailResponse{
{Id: "1"},
{Id: "2"},
},
}
err := json.NewEncoder(w).Encode(&ret)
if err != nil {
panic(err)
}
})
req := []*SendEmailRequest{
{
To: []string{"d@e.com"},
},
{
To: []string{"d@e.com"},
},
}
resp, err := client.Batch.Send(req)
if err != nil {
t.Errorf("BatchEmail.Send returned error: %v", err)
}
assert.Equal(t, resp.Data[0].Id, "1")
assert.Equal(t, resp.Data[1].Id, "2")
}