mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
Windows has no sendmail, so let's exclude those tests for Windows
This commit is contained in:
parent
d653cdc782
commit
7b5b4fa52b
2 changed files with 29 additions and 24 deletions
29
msg_nowin_test.go
Normal file
29
msg_nowin_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
//go:build !windows
|
||||
|
||||
package mail
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestMsg_WriteToSendmailWithCommand tests the WriteToSendmailWithCommand() method of the Msg
|
||||
func TestMsg_WriteToSendmailWithCommand(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
sp string
|
||||
sf bool
|
||||
}{
|
||||
{"Sendmail path: /dev/null", "/dev/null", true},
|
||||
{"Sendmail path: /bin/cat", "/bin/cat", true},
|
||||
{"Sendmail path: /is/invalid", "/is/invalid", true},
|
||||
{"Sendmail path: /bin/echo", "/bin/echo", false},
|
||||
}
|
||||
m := NewMsg()
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
m.SetBodyString(TypeTextPlain, "Plain")
|
||||
if err := m.WriteToSendmailWithCommand(tt.sp); err != nil && !tt.sf {
|
||||
t.Errorf("WriteToSendmailWithCommand() failed: %s", err)
|
||||
}
|
||||
m.Reset()
|
||||
})
|
||||
}
|
||||
}
|
24
msg_test.go
24
msg_test.go
|
@ -1138,27 +1138,3 @@ func TestMsg_Write(t *testing.T) {
|
|||
fmt.Printf("%s", wbuf.String())
|
||||
}
|
||||
}
|
||||
|
||||
// TestMsg_WriteToSendmailWithCommand tests the WriteToSendmailWithCommand() method of the Msg
|
||||
func TestMsg_WriteToSendmailWithCommand(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
sp string
|
||||
sf bool
|
||||
}{
|
||||
{"Sendmail path: /dev/null", "/dev/null", true},
|
||||
{"Sendmail path: /bin/cat", "/bin/cat", true},
|
||||
{"Sendmail path: /is/invalid", "/is/invalid", true},
|
||||
{"Sendmail path: /bin/echo", "/bin/echo", false},
|
||||
}
|
||||
m := NewMsg()
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
m.SetBodyString(TypeTextPlain, "Plain")
|
||||
if err := m.WriteToSendmailWithCommand(tt.sp); err != nil && !tt.sf {
|
||||
t.Errorf("WriteToSendmailWithCommand() failed: %s", err)
|
||||
}
|
||||
m.Reset()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue