onasty/internal/mailer/testing_mailer_test.go (view raw)
Smirnov Oleksandr
Smirnov Oleksandr
ss2316544@gmail.com chore(golangci-lint): upgrade config (#14)..., 1 year ago
ss2316544@gmail.com chore(golangci-lint): upgrade config (#14)..., 1 year ago
| 1 | package mailer |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/stretchr/testify/assert" |
| 8 | "github.com/stretchr/testify/require" |
| 9 | ) |
| 10 | |
| 11 | func TestMailer_Send(t *testing.T) { |
| 12 | m := NewTestMailer() |
| 13 | assert.Empty(t, m.emails) |
| 14 | |
| 15 | email := "test@mail.com" |
| 16 | err := m.Send(context.TODO(), email, "", "content") |
| 17 | require.NoError(t, err) |
| 18 | |
| 19 | assert.Equal(t, "content", m.emails[email]) |
| 20 | } |
| 21 | |
| 22 | func TestMailer_GetLastSentEmailToEmail(t *testing.T) { |
| 23 | email := "test@mail.com" |
| 24 | content := "content" |
| 25 | |
| 26 | m := NewTestMailer() |
| 27 | assert.Empty(t, m.emails) |
| 28 | |
| 29 | m.emails[email] = content |
| 30 | |
| 31 | c := m.GetLastSentEmailToEmail(email) |
| 32 | assert.Equal(t, content, c) |
| 33 | } |