2026-09-23 09:40:59 +08:00
|
|
|
package notify
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestBuildMailBody(t *testing.T) {
|
|
|
|
|
content := FormatAlert("test", "标题", "正文")
|
|
|
|
|
body := string(buildMailBody("from@example.com", []string{"to@example.com"}, content.Subject, content.PlainBody))
|
2026-10-01 16:54:35 +08:00
|
|
|
if !strings.Contains(body, "Subject: [Havline]") {
|
2026-09-23 09:40:59 +08:00
|
|
|
t.Fatalf("missing subject: %s", body)
|
|
|
|
|
}
|
|
|
|
|
if !strings.Contains(body, "正文") {
|
|
|
|
|
t.Fatalf("missing message: %s", body)
|
|
|
|
|
}
|
|
|
|
|
}
|