-
Notifications
You must be signed in to change notification settings - Fork 6
/
admin_test.go
120 lines (86 loc) · 2.24 KB
/
admin_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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package main
import (
//"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
var (
provider = GCE
zoneName = "us-east-1"
trafficZoneName = "us-west-1"
)
func TestNewAdminPanel(t *testing.T) {
p := NewAdminPanel()
assert.NotNil(t, p)
}
func TestAdminPanelAddZone(t *testing.T) {
p := NewAdminPanel()
assert.NotNil(t, p)
z := NewZone(provider, "")
z.Name = zoneName
p.add(z)
assert.True(t, len(p.AllZones()) > 0)
assert.True(t, p.exists(zoneName))
}
func TestAdminPanelPingZone(t *testing.T) {
p := NewAdminPanel()
assert.NotNil(t, p)
z := NewZone(provider, "")
z.Name = zoneName
z.Traffic[trafficZoneName] = 123456
p.Ping(*z)
assert.True(t, len(p.AllZones()) > 0)
assert.True(t, p.exists(zoneName))
assert.Equal(t, 123456, p.get(zoneName).Traffic[trafficZoneName])
}
func TestAdminPanelPingExistingZone(t *testing.T) {
p := NewAdminPanel()
assert.NotNil(t, p)
z := NewZone(provider, "")
z.Name = zoneName
z.Traffic[trafficZoneName] = 123456
p.Ping(*z)
assert.True(t, len(p.AllZones()) > 0)
assert.True(t, p.exists(zoneName))
assert.Equal(t, 123456, p.get(zoneName).Traffic[trafficZoneName])
z2 := NewZone(provider, "")
z2.Name = zoneName
z2.Traffic[trafficZoneName] = 4
p.Ping(*z2)
assert.True(t, len(p.AllZones()) > 0)
assert.True(t, p.exists(zoneName))
assert.Equal(t, 123460, p.get(zoneName).Traffic[trafficZoneName])
}
func TestAdminPanelEnableZone(t *testing.T) {
p := NewAdminPanel()
assert.NotNil(t, p)
z := NewZone(provider, "")
z.Name = zoneName
z.Traffic[trafficZoneName] = 123456
p.add(z)
p.Enable(z.Name)
assert.True(t, p.get(zoneName).Ready)
}
func TestAdminPanelDisableZone(t *testing.T) {
p := NewAdminPanel()
assert.NotNil(t, p)
z := NewZone(provider, "")
z.Name = zoneName
z.Traffic[trafficZoneName] = 123456
p.add(z)
p.Disable(z.Name)
assert.False(t, p.get(zoneName).Ready)
}
func TestAdminPanelEnablePingZone(t *testing.T) {
p := NewAdminPanel()
assert.NotNil(t, p)
z := NewZone(provider, "")
z.Name = zoneName
z.Traffic[trafficZoneName] = 123456
p.Ping(*z)
p.Enable(z.Name)
assert.True(t, p.get(zoneName).Ready)
assert.True(t, len(p.AllZones()) > 0)
assert.True(t, p.exists(zoneName))
assert.Equal(t, 123456, p.get(zoneName).Traffic[trafficZoneName])
}