all repos

onasty @ 20c3a33f04e0abf59318a9f8f5738424f7f4f906

a one-time notes service

onasty/internal/mailer/testing_mailer_test.go(view raw)

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
package mailer

import (
	"context"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestMailer_Send(t *testing.T) {
	m := NewTestMailer()
	assert.Empty(t, m.emails)

	email := "test@mail.com"
	err := m.Send(context.TODO(), email, "", "content")
	require.NoError(t, err)

	assert.Equal(t, "content", m.emails[email])
}

func TestMailer_GetLastSentEmailToEmail(t *testing.T) {
	m := NewTestMailer()
	assert.Empty(t, m.emails)

	email := "test@mail.com"
	content := "content"
	err := m.Send(context.TODO(), email, "", content)
	require.NoError(t, err)

	c := m.GetLastSentEmailToEmail(email)
	assert.Equal(t, content, c)
}