Этот коммит содержится в:
Chris
2017-11-23 08:44:19 -06:00
коммит произвёл Joram Wilander
родитель 1ccf093803
Коммит bbb301b7de
6 изменённых файлов: 27 добавлений и 27 удалений

Просмотреть файл

@@ -103,10 +103,6 @@ func TestConnection(config *model.Config) {
defer c.Close()
}
func SendMail(to, subject, htmlBody string) *model.AppError {
return SendMailUsingConfig(to, subject, htmlBody, Cfg)
}
func SendMailUsingConfig(to, subject, htmlBody string, config *model.Config) *model.AppError {
if !config.EmailSettings.SendEmailNotifications || len(config.EmailSettings.SMTPServer) == 0 {
return nil

Просмотреть файл

@@ -9,30 +9,30 @@ import (
)
func TestMailConnection(t *testing.T) {
LoadGlobalConfig("config.json")
cfg := LoadGlobalConfig("config.json")
if conn, err := connectToSMTPServer(Cfg); err != nil {
if conn, err := connectToSMTPServer(cfg); err != nil {
t.Log(err)
t.Fatal("Should connect to the STMP Server")
} else {
if _, err1 := newSMTPClient(conn, Cfg); err1 != nil {
if _, err1 := newSMTPClient(conn, cfg); err1 != nil {
t.Log(err)
t.Fatal("Should get new smtp client")
}
}
Cfg.EmailSettings.SMTPServer = "wrongServer"
Cfg.EmailSettings.SMTPPort = "553"
cfg.EmailSettings.SMTPServer = "wrongServer"
cfg.EmailSettings.SMTPPort = "553"
if _, err := connectToSMTPServer(Cfg); err == nil {
if _, err := connectToSMTPServer(cfg); err == nil {
t.Log(err)
t.Fatal("Should not to the STMP Server")
}
}
func TestSendMail(t *testing.T) {
LoadGlobalConfig("config.json")
func TestSendMailUsingConfig(t *testing.T) {
cfg := LoadGlobalConfig("config.json")
T = GetUserTranslations("en")
var emailTo string = "test@example.com"
@@ -42,7 +42,7 @@ func TestSendMail(t *testing.T) {
//Delete all the messages before check the sample email
DeleteMailBox(emailTo)
if err := SendMail(emailTo, emailSubject, emailBody); err != nil {
if err := SendMailUsingConfig(emailTo, emailSubject, emailBody, cfg); err != nil {
t.Log(err)
t.Fatal("Should connect to the STMP Server")
} else {