@@ -12,16 +12,40 @@ import (
12
12
"github.com/Azure/azure-container-networking/testutils"
13
13
)
14
14
15
+ var errStore = errors .New ("store error" )
16
+
17
+ const ifName = "eth0"
18
+
15
19
func TestManager (t * testing.T ) {
16
20
RegisterFailHandler (Fail )
17
21
RunSpecs (t , "Manager Suite" )
18
22
}
19
23
20
24
var _ = Describe ("Test Manager" , func () {
25
+ Describe ("Test AddExternalInterface" , func () {
26
+ Context ("When adding the external interface" , func () {
27
+ It ("Should not write to the store" , func () {
28
+ // accessing the store should result in an error
29
+ dataStore := & testutils.KeyValueStoreMock {
30
+ WriteError : errStore ,
31
+ ReadError : errStore ,
32
+ }
33
+ nm := & networkManager {
34
+ ExternalInterfaces : map [string ]* externalInterface {},
35
+ store : dataStore ,
36
+ }
37
+ nm .ExternalInterfaces [ifName ] = & externalInterface {
38
+ Name : ifName ,
39
+ }
40
+ err := nm .AddExternalInterface (ifName , "10.10.10.0/24" )
41
+ Expect (err ).NotTo (HaveOccurred ())
42
+ })
43
+ })
44
+ })
45
+
21
46
Describe ("Test deleteExternalInterface" , func () {
22
47
Context ("When external interface not found" , func () {
23
48
It ("Should return nil" , func () {
24
- ifName := "eth0"
25
49
nm := & networkManager {
26
50
ExternalInterfaces : map [string ]* externalInterface {},
27
51
}
@@ -32,7 +56,6 @@ var _ = Describe("Test Manager", func() {
32
56
33
57
Context ("When external interface found" , func () {
34
58
It ("Should delete external interface" , func () {
35
- ifName := "eth0"
36
59
nm := & networkManager {
37
60
ExternalInterfaces : map [string ]* externalInterface {},
38
61
}
@@ -78,7 +101,7 @@ var _ = Describe("Test Manager", func() {
78
101
79
102
Context ("When GetModificationTime error and not rebooted" , func () {
80
103
It ("Should populate pointers" , func () {
81
- extIfName := "eth0"
104
+ extIfName := ifName
82
105
nwId := "nwId"
83
106
nm := & networkManager {
84
107
store : & testutils.KeyValueStoreMock {
@@ -135,14 +158,13 @@ var _ = Describe("Test Manager", func() {
135
158
nm := & networkManager {
136
159
ExternalInterfaces : map [string ]* externalInterface {},
137
160
}
138
- num := nm .GetNumberOfEndpoints ("eth0" , "" )
161
+ num := nm .GetNumberOfEndpoints (ifName , "" )
139
162
Expect (num ).To (Equal (0 ))
140
163
})
141
164
})
142
165
143
166
Context ("When Networks is nil" , func () {
144
167
It ("Should return 0" , func () {
145
- ifName := "eth0"
146
168
nm := & networkManager {
147
169
ExternalInterfaces : map [string ]* externalInterface {},
148
170
}
@@ -154,7 +176,6 @@ var _ = Describe("Test Manager", func() {
154
176
155
177
Context ("When network not found" , func () {
156
178
It ("Should return 0" , func () {
157
- ifName := "eth0"
158
179
nm := & networkManager {
159
180
ExternalInterfaces : map [string ]* externalInterface {},
160
181
}
@@ -168,7 +189,6 @@ var _ = Describe("Test Manager", func() {
168
189
169
190
Context ("When endpoints is nil" , func () {
170
191
It ("Should return 0" , func () {
171
- ifName := "eth0"
172
192
nwId := "nwId"
173
193
nm := & networkManager {
174
194
ExternalInterfaces : map [string ]* externalInterface {},
@@ -184,7 +204,6 @@ var _ = Describe("Test Manager", func() {
184
204
185
205
Context ("When endpoints is found" , func () {
186
206
It ("Should return the length of endpoints" , func () {
187
- ifName := "eth0"
188
207
nwId := "nwId"
189
208
nm := & networkManager {
190
209
ExternalInterfaces : map [string ]* externalInterface {},
0 commit comments