Fxied cores tests

This commit is contained in:
porosnicuadrian
2021-06-30 09:42:29 +03:00
committed by Dan Christian Bogos
parent 7531215df0
commit 23bca82823
3 changed files with 13 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ package cores
import (
"reflect"
"runtime"
"sync"
"testing"
"time"
@@ -35,12 +36,18 @@ func TestNewCoreService(t *testing.T) {
stopchan := make(chan struct{}, 1)
caps := engine.NewCaps(1, utils.MetaBusy)
sts := engine.NewCapsStats(cfgDflt.CoreSCfg().CapsStatsInterval, caps, stopchan)
shdWg := new(sync.WaitGroup)
shdChan := utils.NewSyncedChan()
stopMemPrf := make(chan struct{})
expected := &CoreService{
cfg: cfgDflt,
CapsStats: sts,
shdWg: shdWg,
shdChan: shdChan,
stopMemPrf: stopMemPrf,
cfg: cfgDflt,
CapsStats: sts,
}
rcv := NewCoreService(cfgDflt, caps, nil, stopchan)
rcv := NewCoreService(cfgDflt, caps, nil, stopchan, shdWg, stopMemPrf, shdChan)
if !reflect.DeepEqual(expected, rcv) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
@@ -55,7 +62,7 @@ func TestCoreServiceStatus(t *testing.T) {
caps := engine.NewCaps(1, utils.MetaBusy)
stopChan := make(chan struct{}, 1)
cores := NewCoreService(cfgDflt, caps, nil, stopChan)
cores := NewCoreService(cfgDflt, caps, nil, stopChan, nil, nil, nil)
args := &utils.TenantWithAPIOpts{
Tenant: "cgrates.org",
APIOpts: map[string]interface{}{},

View File

@@ -51,7 +51,7 @@ func TestCoreSReload(t *testing.T) {
coreRPC := make(chan rpcclient.ClientConnector, 1)
anz := NewAnalyzerService(cfg, server, filterSChan, shdChan, make(chan rpcclient.ClientConnector, 1), srvDep)
caps := engine.NewCaps(1, "test_caps")
coreS := NewCoreService(cfg, caps, server, coreRPC, anz, nil, srvDep)
coreS := NewCoreService(cfg, caps, server, coreRPC, anz, nil, nil, nil, nil, srvDep)
engine.NewConnManager(cfg, nil)
srvMngr.AddServices(coreS,
NewLoaderService(cfg, db, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil, anz, srvDep), db)

View File

@@ -41,7 +41,7 @@ func TestCoreSCoverage(t *testing.T) {
srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
anz := NewAnalyzerService(cfg, server, filterSChan, shdChan, make(chan rpcclient.ClientConnector, 1), srvDep)
srv := NewCoreService(cfg, caps, server,
internalCoreSChan, anz, nil, srvDep)
internalCoreSChan, anz, nil, nil, nil, nil, srvDep)
if srv == nil {
t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(srv))
}