Skip to content

Commit 7e7811b

Browse files
committed
Fix test
1 parent 302bb33 commit 7e7811b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

modules/setting/mailer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func loadMailerFrom(rootCfg ConfigProvider) {
7070
return
7171
}
7272

73-
// Handle Deprecations and map on to new configuration
7473
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
7574
// if these are removed, the warning will not be shown
7675
removedSettingWarning(rootCfg, "mailer", "MAILER_TYPE", "mailer", "PROTOCOL", "v1.19.0")

modules/setting/mailer_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package setting
55

66
import (
7+
"net"
8+
"strings"
79
"testing"
810

911
"github.com/stretchr/testify/assert"
@@ -20,7 +22,7 @@ func Test_loadMailerFrom(t *testing.T) {
2022
SMTPPort: "123",
2123
},
2224
":123": {
23-
SMTPAddr: "127.0.0.1",
25+
SMTPAddr: "",
2426
SMTPPort: "123",
2527
},
2628
}
@@ -29,7 +31,14 @@ func Test_loadMailerFrom(t *testing.T) {
2931
cfg, _ := NewConfigProviderFromData("")
3032
sec := cfg.Section("mailer")
3133
sec.NewKey("ENABLED", "true")
32-
sec.NewKey("HOST", host)
34+
if strings.Contains(host, ":") {
35+
addr, port, err := net.SplitHostPort(host)
36+
assert.NoError(t, err)
37+
sec.NewKey("SMTP_ADDR", addr)
38+
sec.NewKey("SMTP_PORT", port)
39+
} else {
40+
sec.NewKey("SMTP_ADDR", host)
41+
}
3342

3443
// Check mailer setting
3544
loadMailerFrom(cfg)

0 commit comments

Comments
 (0)