forked from appscode/go-hetzner
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathip_test.go
More file actions
111 lines (92 loc) · 1.97 KB
/
ip_test.go
File metadata and controls
111 lines (92 loc) · 1.97 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package hetzner
import "testing"
// No money to order a new ip to test :(
func TestIPList(t *testing.T) {
IPs, resp, err := client.IP.List()
if err != nil && resp.StatusCode != 404 {
t.Error(err)
return
}
if resp.StatusCode == 404 {
t.Error("No IP addresses found")
return
}
t.Logf("Found %d IPs", len(IPs))
}
func TestIPGet(t *testing.T) {
IPs, resp, err := client.IP.Get(testingServer.ServerIP)
if err != nil && resp.StatusCode != 404 {
t.Error(err)
return
}
if resp.StatusCode == 404 {
t.Error("IP address not found")
return
}
t.Logf("IP: %+v\n", IPs.ServerIP)
}
func TestIPUpdateWarring(t *testing.T) {
IPs, resp, err := client.IP.UpdateWarring(
&IPUpdateRequest{
IP: testingServer.ServerIP,
TrafficWarnings: "true",
TrafficHourly: "100",
TrafficDaily: "100",
TrafficMonthly: "100",
},
)
if err != nil && resp.StatusCode != 404 {
t.Error(err)
return
}
if resp.StatusCode == 404 {
t.Error("IP address not found")
return
}
if IPs.TrafficWarnings != true {
t.Error("Update traffic warning failed")
return
}
IPs, resp, err = client.IP.UpdateWarring(
&IPUpdateRequest{
IP: testingServer.ServerIP,
TrafficWarnings: "false",
},
)
if err != nil && resp.StatusCode != 404 {
t.Error(err)
return
}
if resp.StatusCode == 404 {
t.Error("IP address not found")
return
}
if IPs.TrafficWarnings != false {
t.Error("Update traffic warning failed")
return
}
}
func TestIPGetMac(t *testing.T) {
IPs, _, err := client.IP.GetMac(testingServer.ServerIP)
if err != nil {
t.Error(err)
return
}
t.Logf("IP Mac: %+v\n", IPs.Mac)
}
func TestIPCreateMac(t *testing.T) {
IPs, _, err := client.IP.CreateMac(testingServer.ServerIP)
if err != nil {
t.Error(err)
return
}
t.Logf("IP Mac: %+v\n", IPs.Mac)
}
func TestIPDeleteMac(t *testing.T) {
IPs, _, err := client.IP.DeleteMac(testingServer.ServerIP)
if err != nil {
t.Error(err)
return
}
t.Logf("IP Mac: %+v\n", IPs.Mac)
}