mock the mail server using a channel to read

This commit is contained in:
vinchent 2024-07-17 22:37:56 +02:00
parent b1d3095c89
commit c88974788f

View File

@ -39,6 +39,12 @@ func TestMain(m *testing.M) {
app.Session = session
mailChan := make(chan models.MailData)
app.MailChan = mailChan
defer close(mailChan)
listenForMail()
tc, err := CreateTestTemplateCache()
if err != nil {
log.Fatalf("cannot create template cache: %s", err)
@ -135,3 +141,11 @@ func CreateTestTemplateCache() (map[string]*template.Template, error) {
return myCache, nil
}
func listenForMail() {
go func() {
for {
<-app.MailChan
}
}()
}