forked from VadimIpatov/go-zabbix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction_test.go
74 lines (57 loc) · 1.52 KB
/
action_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
package zabbix
import (
"testing"
)
func TestGetAllActions(t *testing.T) {
session := GetTestSession(t)
params := ActionGetParams{}
actions, err := session.GetActions(params)
if err != nil {
t.Fatalf("Error getting actions: %v", err)
}
if len(actions) == 0 {
t.Fatal("No actions found")
}
for i, action := range actions {
if action.ActionID == "" {
t.Fatalf("Action %d has no Action ID", i)
}
t.Log(action.ActionID, action.Name)
if action.Name == "" {
t.Fatalf("Action %d has no name", i)
}
if action.EventType == EventSourceTrigger && action.ProblemMessageSubject == "" {
t.Fatalf("Action %d has no problem message subject", i)
}
}
t.Logf("Validated %d Actions", len(actions))
}
func TestGetTriggerActions(t *testing.T) {
session := GetTestSession(t)
filterTriggerSource := map[string]interface{}{"eventsource": "0"}
params := ActionGetParams{
GetParameters: GetParameters{
Filter: filterTriggerSource,
},
}
actions, err := session.GetActions(params)
if err != nil {
t.Fatalf("Error getting actions: %v", err)
}
if len(actions) == 0 {
t.Fatal("No actions found")
}
for i, action := range actions {
if action.ActionID == "" {
t.Fatalf("Action %d has no Action ID", i)
}
t.Log(action.ActionID, action.Name)
if action.Name == "" {
t.Fatalf("Action %d has no name", i)
}
if action.EventType == EventSourceTrigger && action.ProblemMessageSubject == "" {
t.Fatalf("Action %d has no problem message subject", i)
}
}
t.Logf("Validated %d Actions", len(actions))
}