forked from claranet/go-zabbix-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproxy_test.go
41 lines (38 loc) · 1.29 KB
/
proxy_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
package zabbix_test
import (
"encoding/json"
zapi "github.com/atypon/go-zabbix-api"
"log"
"testing"
)
func TestPassiveProxy(t *testing.T) {
proxyInterfaces := &zapi.ProxyInterface{IP: "10.1.1.1", Port: "1234", UseIP: 1}
passiveProxy := &zapi.Proxy{Name: "TestZabbixProxy", Status: zapi.PassiveProxy, Interface: proxyInterfaces}
log.Printf("%+v", passiveProxy)
//testCRUDAPIObjectOperations(t, passiveProxy)
testCreateAPIObject(t, passiveProxy)
defer testDeleteAPIObject(t, passiveProxy)
passiveProxy = &zapi.Proxy{ProxyID: passiveProxy.ProxyID}
testReadAPIObject(t, passiveProxy)
jsonInterface, err := json.Marshal(passiveProxy.Interface)
if err != nil {
t.Fatal(err)
}
err = json.Unmarshal(jsonInterface, proxyInterfaces)
if err != nil {
t.Fatal(err)
}
passiveProxy.Interface = proxyInterfaces
log.Printf("%+v", passiveProxy)
testUpdateAPIObject(t, passiveProxy)
}
func TestActiveProxy(t *testing.T) {
activeProxy := &zapi.Proxy{Name: "TestZabbixProxy", Status: zapi.ActiveProxy, Interface: nil}
log.Printf("%+v", activeProxy)
//testCRUDAPIObjectOperations(t, activeProxy)
testCreateAPIObject(t, activeProxy)
defer testDeleteAPIObject(t, activeProxy)
activeProxy = &zapi.Proxy{ProxyID: activeProxy.ProxyID}
testReadAPIObject(t, activeProxy)
testUpdateAPIObject(t, activeProxy)
}