VOL-1837,update comment's for unit test file's
review comments updated
Change-Id: Ib4d8d5d47c906c21fd54f5d68aa57c98763a8697
diff --git a/adaptercore/openolt_test.go b/adaptercore/openolt_test.go
index bac94a3..cf48cc3 100644
--- a/adaptercore/openolt_test.go
+++ b/adaptercore/openolt_test.go
@@ -14,6 +14,12 @@
* limitations under the License.
*/
+/*
+This file contains unit test cases for functions in the file openolt.go.
+This file also implements the fields struct to mock the Openolt and few utility functions.
+*/
+
+//Package adaptercore provides the utility for olt devices, flows and statistics
package adaptercore
import (
@@ -32,6 +38,7 @@
"github.com/opencord/voltha-protos/go/voltha"
)
+// mocks the OpenOLT struct.
type fields struct {
deviceHandlers map[string]*DeviceHandler
coreProxy *com.CoreProxy
@@ -47,8 +54,8 @@
ctx context.Context
}
+// mockOlt mocks OpenOLT struct.
func mockOlt() *fields {
- //var newOlt fields
dh := newMockDeviceHandler()
newOlt := &fields{}
newOlt.deviceHandlers = map[string]*DeviceHandler{}
@@ -56,6 +63,7 @@
return newOlt
}
+// testOltObject maps fields type to OpenOLt type.
func testOltObject(testOlt *fields) *OpenOLT {
return &OpenOLT{
deviceHandlers: testOlt.deviceHandlers,
@@ -71,6 +79,7 @@
}
}
+// mockDevice mocks Device.
func mockDevice() *voltha.Device {
device := &voltha.Device{
Id: "olt",
diff --git a/adaptercore/resourcemanager/resourcemanager_test.go b/adaptercore/resourcemanager/resourcemanager_test.go
index 1373a54..7210b3b 100644
--- a/adaptercore/resourcemanager/resourcemanager_test.go
+++ b/adaptercore/resourcemanager/resourcemanager_test.go
@@ -14,6 +14,13 @@
* limitations under the License.
*/
+/*
+This file contains unit test cases for functions in the file resourcemanager.go.
+This file also implements the Client interface to mock the kv-client, fields struct to mock OpenOltResourceMgr
+and few utility functions.
+*/
+
+//Package adaptercore provides the utility for olt devices, flows and statistics
package resourcemanager
import (
@@ -56,6 +63,7 @@
FlowIDpool = "flow_id_pool"
)
+// fields mocks OpenOltResourceMgr struct.
type fields struct {
DeviceID string
HostAndPort string
@@ -67,9 +75,12 @@
DevInfo *openolt.DeviceInfo
ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
}
+
+// MockKVClient mocks the AdapterProxy interface.
type MockResKVClient struct {
}
+// getResMgr mocks OpenOltResourceMgr struct.
func getResMgr() *fields {
var resMgr fields
resMgr.KVStore = &model.Backend{
@@ -103,6 +114,8 @@
resMgr.ResourceMgrs[2] = ponMgr
return &resMgr
}
+
+// List function implemented for KVClient.
func (kvclient *MockResKVClient) List(key string, timeout int, lock ...bool) (map[string]*kvstore.KVPair, error) {
return nil, errors.New("key didn't find")
}
@@ -216,6 +229,7 @@
func (kvclient *MockResKVClient) Close() {
}
+// testResMgrObject maps fields type to OpenOltResourceMgr type.
func testResMgrObject(testResMgr *fields) *OpenOltResourceMgr {
return &OpenOltResourceMgr{
DeviceID: testResMgr.DeviceID,