|
| 1 | +package tempmail |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "testing" |
| 6 | + "time" |
| 7 | + |
| 8 | + "github.com/stretchr/testify/assert" |
| 9 | + "github.com/stretchr/testify/mock" |
| 10 | + "github.com/stretchr/testify/require" |
| 11 | +) |
| 12 | + |
| 13 | +func TestClient_ListEmailMessages(t *testing.T) { |
| 14 | + mDoer := newMockDoer(t) |
| 15 | + mDoer.EXPECT().Do(mock.Anything).Return(newTestResponse(200, readFile(t, "testdata/list_email_messages.json")), nil) |
| 16 | + |
| 17 | + c := newClient() |
| 18 | + c.doer = mDoer |
| 19 | + r, resp, err := c. ListEmailMessages( context. Background(), "[email protected]") |
| 20 | + require.NoError(t, err) |
| 21 | + assert.Equal(t, 200, resp.StatusCode) |
| 22 | + require.Len(t, r.Messages, 1) |
| 23 | + assert.Equal(t, ListEmailMessagesMessageResponse{ |
| 24 | + ID: "01JE97FT950QRPDYGDXJ4R43QR", |
| 25 | + |
| 26 | + |
| 27 | + CC: [] string{ "[email protected]"}, |
| 28 | + Subject: "Your account has been created", |
| 29 | + BodyText: "Welcome to our service! Your account has been created successfully.", |
| 30 | + BodyHTML: "<p>Welcome to our service! Your account has been created successfully.</p>", |
| 31 | + CreatedAt: time.Date(2022, 1, 31, 22, 0, 0, 0, time.UTC), |
| 32 | + Attachments: []ListEmailMessagesAttachmentResponse{ |
| 33 | + { |
| 34 | + ID: "01JE97K1PBYVGKY0PVE3KXSBF9", |
| 35 | + Name: "invoice.pdf", |
| 36 | + Size: 5120, |
| 37 | + }, |
| 38 | + }, |
| 39 | + }, r.Messages[0]) |
| 40 | +} |
0 commit comments