2022-10-17 12:04:29 +00:00
|
|
|
package mail
|
|
|
|
|
|
|
|
import (
|
2023-01-13 06:04:32 +00:00
|
|
|
"github/fthvgb1/wp-go/internal/pkg/config"
|
2022-10-17 12:04:29 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSendMail(t *testing.T) {
|
2022-11-16 07:46:55 +00:00
|
|
|
err := config.InitConfig("../config.yaml")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-10-17 12:04:29 +00:00
|
|
|
type args struct {
|
|
|
|
mailTo []string
|
|
|
|
subject string
|
|
|
|
body string
|
2022-11-16 07:46:55 +00:00
|
|
|
files []string
|
2022-10-17 12:04:29 +00:00
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "t1",
|
|
|
|
args: args{
|
|
|
|
mailTo: []string{"fthvgb1@163.com"},
|
|
|
|
subject: "测试发邮件",
|
|
|
|
body: "测试发邮件",
|
2022-11-16 07:46:55 +00:00
|
|
|
files: []string{"/home/xing/Downloads/favicon.ico"},
|
2022-10-17 12:04:29 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2022-11-16 07:46:55 +00:00
|
|
|
if err := SendMail(tt.args.mailTo, tt.args.subject, tt.args.body, tt.args.files...); (err != nil) != tt.wantErr {
|
2022-10-17 12:04:29 +00:00
|
|
|
t.Errorf("SendMail() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|