forked from AlekSi/zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
item_test.go
52 lines (43 loc) · 965 Bytes
/
item_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
package zabbix_test
import (
. "."
"testing"
)
func CreateItem(app *Application, t *testing.T) *Item {
items := Items{{
HostId: app.HostId,
Key: "key.lala.laa",
Name: "name for key",
Type: ZabbixTrapper,
ApplicationIds: []string{app.ApplicationId},
}}
err := getAPI(t).ItemsCreate(items)
if err != nil {
t.Fatal(err)
}
return &items[0]
}
func DeleteItem(item *Item, t *testing.T) {
err := getAPI(t).ItemsDelete(Items{*item})
if err != nil {
t.Fatal(err)
}
}
func TestItems(t *testing.T) {
api := getAPI(t)
group := CreateHostGroup(t)
defer DeleteHostGroup(group, t)
host := CreateHost(group, t)
defer DeleteHost(host, t)
app := CreateApplication(host, t)
defer DeleteApplication(app, t)
items, err := api.ItemsGetByApplicationId(app.ApplicationId)
if err != nil {
t.Fatal(err)
}
if len(items) != 0 {
t.Fatal("Found items")
}
item := CreateItem(app, t)
DeleteItem(item, t)
}