- 公网反代:Nginx 状态卡片(版本 / 运行状态 / 配置校验 / 端口监听) - 部署设置第一、二梯队(HTTPS 开关、安全头、限流、连接数、仅中国大陆 IP) - 隧道检测兼容 frps v0.68 / v0.71(V2 与旧版端点) - 恢复被清空的 internal/frp/store.go、internal/api/ddns_handler.go、web/src/views/DdnsView.vue
29 lines
921 B
Go
29 lines
921 B
Go
package notify
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestFormatAlert(t *testing.T) {
|
|
at := time.Date(2026, 9, 18, 15, 49, 0, 0, time.FixedZone("CST", 8*3600))
|
|
content := FormatAlertAt(EventDDNSIPChange, "DDNS IP 已变更", "example.com\nIPv4: 1.2.3.4 → 5.6.7.8", at)
|
|
|
|
if content.Subject != "[Fonu] 🌐 DDNS IP 已变更" {
|
|
t.Fatalf("unexpected subject: %s", content.Subject)
|
|
}
|
|
if !strings.Contains(content.PlainBody, "example.com") {
|
|
t.Fatalf("missing detail: %s", content.PlainBody)
|
|
}
|
|
if !strings.Contains(content.PlainBody, "Fonu · 2026-09-18 15:49:00") {
|
|
t.Fatalf("missing footer: %s", content.PlainBody)
|
|
}
|
|
if !strings.Contains(content.HTMLBody, "<b>") || !strings.Contains(content.HTMLBody, "<pre>") {
|
|
t.Fatalf("unexpected html: %s", content.HTMLBody)
|
|
}
|
|
if content.webhookPayload()["category"] != "DDNS" {
|
|
t.Fatalf("unexpected webhook category: %v", content.webhookPayload())
|
|
}
|
|
}
|