#42: Add test for Msg.WriteToSendmail

This commit is contained in:
Winni Neessen 2022-09-08 15:08:17 +02:00
parent 333c3970e7
commit 6d22a34548
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -9,6 +9,7 @@ package mail
import ( import (
"context" "context"
"os"
"testing" "testing"
"time" "time"
) )
@ -38,3 +39,19 @@ func TestMsg_WriteToSendmailWithContext(t *testing.T) {
}) })
} }
} }
// TestMsg_WriteToSendmail will test the output to the local sendmail command
func TestMsg_WriteToSendmail(t *testing.T) {
_, err := os.Stat(SendmailPath)
if err != nil {
t.Skipf("local sendmail command not found in expected path. Skipping")
}
m := NewMsg()
_ = m.From("Toni Tester <tester@example.com>")
_ = m.To(TestRcpt)
m.SetBodyString(TypeTextPlain, "This is a test")
if err := m.WriteToSendmail(); err != nil {
t.Errorf("WriteToSendmail failed: %s", err)
}
}