@@ -12,16 +12,40 @@ import (
1212 "github.com/Azure/azure-container-networking/testutils"
1313)
1414
15+ var errStore = errors .New ("store error" )
16+
17+ const ifName = "eth0"
18+
1519func TestManager (t * testing.T ) {
1620 RegisterFailHandler (Fail )
1721 RunSpecs (t , "Manager Suite" )
1822}
1923
2024var _ = 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+
2146 Describe ("Test deleteExternalInterface" , func () {
2247 Context ("When external interface not found" , func () {
2348 It ("Should return nil" , func () {
24- ifName := "eth0"
2549 nm := & networkManager {
2650 ExternalInterfaces : map [string ]* externalInterface {},
2751 }
@@ -32,7 +56,6 @@ var _ = Describe("Test Manager", func() {
3256
3357 Context ("When external interface found" , func () {
3458 It ("Should delete external interface" , func () {
35- ifName := "eth0"
3659 nm := & networkManager {
3760 ExternalInterfaces : map [string ]* externalInterface {},
3861 }
@@ -78,7 +101,7 @@ var _ = Describe("Test Manager", func() {
78101
79102 Context ("When GetModificationTime error and not rebooted" , func () {
80103 It ("Should populate pointers" , func () {
81- extIfName := "eth0"
104+ extIfName := ifName
82105 nwId := "nwId"
83106 nm := & networkManager {
84107 store : & testutils.KeyValueStoreMock {
@@ -135,14 +158,13 @@ var _ = Describe("Test Manager", func() {
135158 nm := & networkManager {
136159 ExternalInterfaces : map [string ]* externalInterface {},
137160 }
138- num := nm .GetNumberOfEndpoints ("eth0" , "" )
161+ num := nm .GetNumberOfEndpoints (ifName , "" )
139162 Expect (num ).To (Equal (0 ))
140163 })
141164 })
142165
143166 Context ("When Networks is nil" , func () {
144167 It ("Should return 0" , func () {
145- ifName := "eth0"
146168 nm := & networkManager {
147169 ExternalInterfaces : map [string ]* externalInterface {},
148170 }
@@ -154,7 +176,6 @@ var _ = Describe("Test Manager", func() {
154176
155177 Context ("When network not found" , func () {
156178 It ("Should return 0" , func () {
157- ifName := "eth0"
158179 nm := & networkManager {
159180 ExternalInterfaces : map [string ]* externalInterface {},
160181 }
@@ -168,7 +189,6 @@ var _ = Describe("Test Manager", func() {
168189
169190 Context ("When endpoints is nil" , func () {
170191 It ("Should return 0" , func () {
171- ifName := "eth0"
172192 nwId := "nwId"
173193 nm := & networkManager {
174194 ExternalInterfaces : map [string ]* externalInterface {},
@@ -184,7 +204,6 @@ var _ = Describe("Test Manager", func() {
184204
185205 Context ("When endpoints is found" , func () {
186206 It ("Should return the length of endpoints" , func () {
187- ifName := "eth0"
188207 nwId := "nwId"
189208 nm := & networkManager {
190209 ExternalInterfaces : map [string ]* externalInterface {},
0 commit comments