VOL-3121 - Removing usage of device.Ports
Changed device.Ports usages to GetDevicePort() and ListDevicePorts()
Added port type filter to PortsStateUpdate()
Change-Id: I4fab819a909379ee71e70eb48ac44044e9810185
diff --git a/pkg/mocks/mockCoreProxy.go b/pkg/mocks/mockCoreProxy.go
index 9c99599..37e959e 100644
--- a/pkg/mocks/mockCoreProxy.go
+++ b/pkg/mocks/mockCoreProxy.go
@@ -30,7 +30,8 @@
type MockCoreProxy struct {
// Values to be used in test can reside inside this structure
// TODO store relevant info in this, use this info for negative and positive tests
- Devices map[string]*voltha.Device
+ Devices map[string]*voltha.Device
+ DevicePorts map[string][]*voltha.Port
}
// UpdateCoreReference mock updatesCoreReference
@@ -82,7 +83,7 @@
}
// PortsStateUpdate implements mock PortsStateUpdate
-func (mcp *MockCoreProxy) PortsStateUpdate(ctx context.Context, deviceID string, operStatus voltha.OperStatus_Types) error {
+func (mcp *MockCoreProxy) PortsStateUpdate(ctx context.Context, deviceID string, portTypeFilter uint32, operStatus voltha.OperStatus_Types) error {
if deviceID == "" {
return errors.New("no Device")
}
@@ -97,6 +98,25 @@
return nil
}
+// GetDevicePort implements mock GetDevicePort
+func (mcp *MockCoreProxy) GetDevicePort(ctx context.Context, deviceID string, portID uint32) (*voltha.Port, error) {
+ for _, port := range mcp.DevicePorts[deviceID] {
+ if port.PortNo == portID {
+ return port, nil
+ }
+ }
+ return nil, errors.New("device/port not found")
+}
+
+// ListDevicePorts implements mock ListDevicePorts
+func (mcp *MockCoreProxy) ListDevicePorts(ctx context.Context, deviceID string) ([]*voltha.Port, error) {
+ ports, have := mcp.DevicePorts[deviceID]
+ if !have {
+ return nil, errors.New("device id not found")
+ }
+ return ports, nil
+}
+
// DeviceStateUpdate implements mock DeviceStateUpdate
func (mcp *MockCoreProxy) DeviceStateUpdate(ctx context.Context, deviceID string,
connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error {