Skip to content

Commit

Permalink
feat(template): 模板测试
Browse files Browse the repository at this point in the history
  • Loading branch information
aide-cloud committed Apr 26, 2024
1 parent 21ecbff commit 38a1bb2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/strategy/alarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestFormatter(t *testing.T) {
"__level_id__": "1",
"instance": "test-instance",
"alertname": "test-alert",
"ip": "192.168.1.100",
}
annotations := Annotations{
"summary": "test summary",
Expand Down Expand Up @@ -81,6 +82,11 @@ func TestFormatter(t *testing.T) {
链接地址: {{ .GeneratorURL }}
告警指纹: {{ .Fingerprint }}
当前值: {{ .Value }}
当前时间: {{ now.Format "2006-01-02 15:04:05" }}
是否告警: {{ if contains .Status "firing" }}告警了{{ else }}恢复了{{ end }}
IP:{{ range split .Labels.ip "." }}
an ip {{ . }}
{{- end }}
`
t.Log(Formatter(templateStr, data))
}

0 comments on commit 38a1bb2

Please sign in to comment.