Unittest stability improvements
[ric-plt/submgr.git] / pkg / control / ut_ctrl_submgr_test.go
index 038c20a..ee7bc82 100644 (file)
@@ -56,7 +56,8 @@ func createSubmgrControl(srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc) *te
        mainCtrl.RmrControl.Init("SUBMGRCTL", srcId, rtgSvc)
        mainCtrl.c = NewControl()
        xapp.Logger.Debug("Replacing real db with test db")
-       mainCtrl.c.db = CreateMock() // This overrides real database for testing
+       mainCtrl.c.e2SubsDb = CreateMock()             // This overrides real E2 Subscription database for testing
+       mainCtrl.c.restSubsDb = CreateRestSubsDbMock() // This overrides real REST Subscription database for testing
        xapp.SetReadyCB(mainCtrl.ReadyCB, nil)
        go xapp.RunWithParams(mainCtrl.c, false)
        mainCtrl.WaitCB()
@@ -69,6 +70,7 @@ func (mc *testingSubmgrControl) SimulateRestart(t *testing.T) {
        mainCtrl.c.registry.subIds = nil
        // Initialize subIds slice and subscription map
        mainCtrl.c.registry.Initialize()
+       restDuplicateCtrl.Init()
        // Read subIds and subscriptions from database
        subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
        if err != nil {
@@ -95,8 +97,15 @@ func (mc *testingSubmgrControl) SimulateRestart(t *testing.T) {
        go mainCtrl.c.HandleUncompletedSubscriptions(mainCtrl.c.registry.register)
 }
 
+func (mc *testingSubmgrControl) MakeTransactionNil(t *testing.T, subId uint32) {
+
+       mc.TestLog(t, "Makin transaction nil for SubId=%v", subId)
+       subs := mainCtrl.c.registry.GetSubscription(subId)
+       subs.TheTrans = nil
+}
+
 func (mc *testingSubmgrControl) SetResetTestFlag(t *testing.T, status bool) {
-       mc.TestLog(t, "ResetTestFlag set to %v=", status)
+       mc.TestLog(t, "ResetTestFlag set to %v", status)
        mainCtrl.c.ResetTestFlag = status
 }