forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alert_test.go
92 lines (90 loc) · 1.78 KB
/
alert_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package pipeline
import (
"testing"
)
func TestAlertNode_MarshalJSON(t *testing.T) {
tests := []struct {
name string
node AlertNode
want string
wantErr bool
}{
{
name: "marshal post",
node: AlertNode{
AlertNodeData: &AlertNodeData{
HTTPPostHandlers: []*AlertHTTPPostHandler{
{
URL: "http://howdy.local",
Endpoint: "/endpoint",
},
},
},
},
want: `{
"typeOf": "alert",
"id": "0",
"category": "",
"topic": "",
"alertId": "",
"message": "",
"details": "",
"info": null,
"warn": null,
"crit": null,
"infoReset": null,
"warnReset": null,
"critReset": null,
"useFlapping": false,
"flapLow": 0,
"flapHigh": 0,
"history": 0,
"levelTag": "",
"levelField": "",
"messageField": "",
"durationField": "",
"idTag": "",
"idField": "",
"all": false,
"noRecoveries": false,
"stateChangesOnly": false,
"stateChangesOnlyDuration": 0,
"inhibitors": null,
"post": [
{
"url": "http://howdy.local",
"endpoint": "/endpoint",
"headers": null,
"captureResponse": false,
"timeout": 0,
"skipSSLVerification": false
}
],
"tcp": null,
"email": null,
"exec": null,
"log": null,
"victorOps": null,
"pagerDuty": null,
"pagerDuty2": null,
"pushover": null,
"sensu": null,
"slack": null,
"telegram": null,
"hipChat": null,
"alerta": null,
"opsGenie": null,
"opsGenie2": null,
"talk": null,
"mqtt": null,
"snmpTrap": null,
"kafka": null
}`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
MarshalIndentTestHelper(t, &tt.node, tt.wantErr, tt.want)
})
}
}