Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
adibrastegarnia committed Sep 9, 2020
1 parent d6362af commit 62fb577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 1 addition & 4 deletions pkg/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ package manager

import (
"errors"
"os"
"strings"
"testing"
"time"

"github.com/golang/mock/gomock"
changetypes "github.com/onosproject/onos-config/api/types/change"
Expand All @@ -41,6 +37,7 @@ import (
"strings"
"testing"
"time"
)

const (
test1Cont1ACont2ALeaf2A = "/cont1a/cont2a/leaf2a"
Expand Down
18 changes: 11 additions & 7 deletions pkg/southbound/synchronizer/device_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func setUp(t *testing.T) *AllMocks {
assert.NilError(t, err)

node1 := cluster.NodeID("node1")
mastershipStore, err := mastership.NewLocalStore("TestUpdateDisconnectedDevice", node1)
mastershipStore, err := mastership.NewLocalStore("TestUpdateDevice", node1)
assert.NilError(t, err)

allMocks := AllMocks{
Expand Down Expand Up @@ -78,13 +78,17 @@ func TestUpdateDisconnectedDevice(t *testing.T) {

allMocks.DeviceClient.EXPECT().Update(gomock.Any(), gomock.Any()).Return(&topodevice.UpdateResponse{Device: device1Disconnected}, nil).AnyTimes()

state, err := allMocks.MastershipStore.GetMastership(device1Disconnected.ID)
assert.NilError(t, err)

session1 := &Session{
device: device1Disconnected,
mastershipStore: allMocks.MastershipStore,
deviceStore: allMocks.DeviceStore,
mastershipState: state,
}

err := session1.updateDisconnectedDevice()
err = session1.updateDisconnectedDevice()
assert.NilError(t, err)
updatedDevice, err := session1.deviceStore.Get(device1)
assert.NilError(t, err)
Expand All @@ -98,10 +102,6 @@ func TestUpdateDisconnectedDevice(t *testing.T) {
func TestUpdateConnectedDevice(t *testing.T) {
allMocks := setUp(t)

node1 := cluster.NodeID("node1")
mastershipStore1, err := mastership.NewLocalStore("TestUpdateConnectedDevice", node1)
assert.NilError(t, err)

device1Connected := &topodevice.Device{
ID: device1,
Revision: 1,
Expand All @@ -119,10 +119,14 @@ func TestUpdateConnectedDevice(t *testing.T) {

allMocks.DeviceClient.EXPECT().Update(gomock.Any(), gomock.Any()).Return(&topodevice.UpdateResponse{Device: device1Connected}, nil).AnyTimes()

state, err := allMocks.MastershipStore.GetMastership(device1Connected.ID)
assert.NilError(t, err)

session1 := &Session{
device: device1Connected,
mastershipStore: mastershipStore1,
mastershipStore: allMocks.MastershipStore,
deviceStore: allMocks.DeviceStore,
mastershipState: state,
}

err = session1.updateConnectedDevice()
Expand Down

0 comments on commit 62fb577

Please sign in to comment.