Skip to content

Commit d9e0ec7

Browse files
committed
add ut to ensure store unaffected during add external interface
1 parent e312223 commit d9e0ec7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

network/manager_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,36 @@ import (
1212
"github.com/Azure/azure-container-networking/testutils"
1313
)
1414

15+
var errStore = errors.New("store error")
16+
1517
func TestManager(t *testing.T) {
1618
RegisterFailHandler(Fail)
1719
RunSpecs(t, "Manager Suite")
1820
}
1921

2022
var _ = Describe("Test Manager", func() {
23+
Describe("Test AddExternalInterface", func() {
24+
Context("When adding the external interface", func() {
25+
It("Should not write to the store", func() {
26+
ifName := "eth0"
27+
// accessing the store should result in an error
28+
dataStore := &testutils.KeyValueStoreMock{
29+
WriteError: errStore,
30+
ReadError: errStore,
31+
}
32+
nm := &networkManager{
33+
ExternalInterfaces: map[string]*externalInterface{},
34+
store: dataStore,
35+
}
36+
nm.ExternalInterfaces[ifName] = &externalInterface{
37+
Name: ifName,
38+
}
39+
err := nm.AddExternalInterface(ifName, "10.10.10.0/24")
40+
Expect(err).NotTo(HaveOccurred())
41+
})
42+
})
43+
})
44+
2145
Describe("Test deleteExternalInterface", func() {
2246
Context("When external interface not found", func() {
2347
It("Should return nil", func() {

0 commit comments

Comments
 (0)