VOL-1838 Unit test cases for golang openolt adapter device_handler.go
1.Mocked AdapterproxyIntf and coreproxyIntf Interfaces for unit test cases.
2. Added few unit testcases for the device_handler.go functions
Change-Id: I793d94055d2c0480e614e918c064df51cdf0b0ae
diff --git a/main.go b/main.go
index 30efa84..af7ca2e 100644
--- a/main.go
+++ b/main.go
@@ -21,6 +21,14 @@
"context"
"errors"
"fmt"
+ "os"
+ "os/signal"
+ "strconv"
+ "syscall"
+ "time"
+
+ "github.com/opencord/voltha-go/adapters/adapterif"
+
"github.com/opencord/voltha-go/adapters"
com "github.com/opencord/voltha-go/adapters/common"
"github.com/opencord/voltha-go/common/log"
@@ -31,11 +39,6 @@
"github.com/opencord/voltha-openolt-adapter/config/version"
ic "github.com/opencord/voltha-protos/go/inter_container"
"github.com/opencord/voltha-protos/go/voltha"
- "os"
- "os/signal"
- "strconv"
- "syscall"
- "time"
)
type adapter struct {
@@ -45,9 +48,9 @@
kafkaClient kafka.Client
kvClient kvstore.Client
kip *kafka.InterContainerProxy
- coreProxy *com.CoreProxy
- adapterProxy *com.AdapterProxy
- eventProxy *com.EventProxy
+ coreProxy adapterif.CoreProxy
+ adapterProxy adapterif.AdapterProxy
+ eventProxy adapterif.EventProxy
halted bool
exitChannel chan int
receiverChannels []<-chan *ic.InterContainerMessage
@@ -97,7 +100,8 @@
a.eventProxy = com.NewEventProxy(com.MsgClient(a.kafkaClient), com.MsgTopic(kafka.Topic{Name: a.config.EventTopic}))
// Create the open OLT adapter
- if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.eventProxy, a.config.OnuNumber,
+ if a.iAdapter, err = a.startOpenOLT(ctx, a.kip, a.coreProxy, a.adapterProxy, a.eventProxy,
+ a.config.OnuNumber,
a.config.KVStoreHost, a.config.KVStorePort, a.config.KVStoreType); err != nil {
log.Fatal("error-starting-inter-container-proxy")
}
@@ -207,7 +211,9 @@
return kip, nil
}
-func (a *adapter) startOpenOLT(ctx context.Context, kip *kafka.InterContainerProxy, cp *com.CoreProxy, ap *com.AdapterProxy, ep *com.EventProxy, onuNumber int, kvStoreHost string, kvStorePort int, KVStoreType string) (*ac.OpenOLT, error) {
+func (a *adapter) startOpenOLT(ctx context.Context, kip *kafka.InterContainerProxy,
+ cp adapterif.CoreProxy, ap adapterif.AdapterProxy, ep adapterif.EventProxy, onuNumber int, kvStoreHost string,
+ kvStorePort int, KVStoreType string) (*ac.OpenOLT, error) {
log.Info("starting-open-olt")
var err error
sOLT := ac.NewOpenOLT(ctx, a.kip, cp, ap, ep, onuNumber, kvStoreHost, kvStorePort, KVStoreType)