mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Add abstraction layer above SMTP communication * Fix issues with attachments and sync command * Tests for bad SMTP behavior * Separate tests between async and sync entry points. Test difference between them * Return interface so Wire can properly map types * Address feedback from George
33 lines
645 B
Go
33 lines
645 B
Go
package notifications
|
|
|
|
import "fmt"
|
|
|
|
type FakeMailer struct {
|
|
Sent []*Message
|
|
}
|
|
|
|
func NewFakeMailer() *FakeMailer {
|
|
return &FakeMailer{
|
|
Sent: make([]*Message, 0),
|
|
}
|
|
}
|
|
|
|
func (fm *FakeMailer) Send(messages ...*Message) (int, error) {
|
|
sentEmailsCount := 0
|
|
for _, msg := range messages {
|
|
fm.Sent = append(fm.Sent, msg)
|
|
sentEmailsCount++
|
|
}
|
|
return sentEmailsCount, nil
|
|
}
|
|
|
|
type FakeDisconnectedMailer struct{}
|
|
|
|
func NewFakeDisconnectedMailer() *FakeDisconnectedMailer {
|
|
return &FakeDisconnectedMailer{}
|
|
}
|
|
|
|
func (fdm *FakeDisconnectedMailer) Send(messages ...*Message) (int, error) {
|
|
return 0, fmt.Errorf("connect: connection refused")
|
|
}
|