wp-go/mail/mail_test.go

44 lines
837 B
Go
Raw Normal View History

2022-10-17 12:04:29 +00:00
package mail
import (
2022-11-04 02:38:59 +00:00
"github/fthvgb1/wp-go/config"
2022-10-17 12:04:29 +00:00
"testing"
)
func TestSendMail(t *testing.T) {
2022-11-05 07:07:08 +00:00
config.InitConfig("config.yaml")
2022-10-17 12:04:29 +00:00
type args struct {
mailTo []string
subject string
body string
a []AttacheFile
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "t1",
args: args{
mailTo: []string{"fthvgb1@163.com"},
subject: "测试发邮件",
body: "测试发邮件",
a: []AttacheFile{
{
Name: "附件",
Path: "/home/xing/Downloads/favicon.ico",
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := SendMail(tt.args.mailTo, tt.args.subject, tt.args.body, tt.args.a...); (err != nil) != tt.wantErr {
t.Errorf("SendMail() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}