mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Continuing tests for services
This commit is contained in:
committed by
Dan Christian Bogos
parent
735dc00520
commit
13cbdcfb91
@@ -1548,6 +1548,9 @@ func TestLoadActionProfiles(t *testing.T) {
|
||||
sort.Slice(expected.Targets[0].TargetIDs, func(i, j int) bool {
|
||||
return expected.Targets[0].TargetIDs[i] < expected.Targets[0].TargetIDs[j]
|
||||
})
|
||||
sort.Slice(csvr.actionProfiles[actPrfKey].Targets[0].TargetIDs, func(i, j int) bool {
|
||||
return csvr.actionProfiles[actPrfKey].Targets[0].TargetIDs[i] < csvr.actionProfiles[actPrfKey].Targets[0].TargetIDs[j]
|
||||
})
|
||||
|
||||
if !reflect.DeepEqual(csvr.actionProfiles[actPrfKey], expected) {
|
||||
t.Errorf("Expecting: %+v,\n received: %+v",
|
||||
|
||||
@@ -18,3 +18,63 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package services
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/cores"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
//TestNewActionService for cover testing
|
||||
func TestCoreSCoverage(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
caps := engine.NewCaps(1, "test_caps")
|
||||
server := cores.NewServer(nil)
|
||||
internalCoreSChan := make(chan rpcclient.ClientConnector, 1)
|
||||
filterSChan := make(chan *engine.FilterS, 1)
|
||||
filterSChan <- nil
|
||||
shdChan := utils.NewSyncedChan()
|
||||
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, srvDep)
|
||||
if srv == nil {
|
||||
t.Errorf("\nExpecting <nil>,\n Received <%+v>", utils.ToJSON(srv))
|
||||
}
|
||||
srv2 := NewCoreService(cfg, caps, server,
|
||||
internalCoreSChan, anz, srvDep)
|
||||
if srv2.IsRunning() {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
srv2.cS = &cores.CoreService{}
|
||||
if !srv2.IsRunning() {
|
||||
t.Errorf("Expected service to be running")
|
||||
}
|
||||
err := srv2.Start()
|
||||
if err == nil || err != utils.ErrServiceAlreadyRunning {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
|
||||
}
|
||||
serviceName := srv2.ServiceName()
|
||||
if !reflect.DeepEqual(serviceName, utils.CoreS) {
|
||||
t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.CoreS, serviceName)
|
||||
}
|
||||
shouldRun := srv2.ShouldRun()
|
||||
if !reflect.DeepEqual(shouldRun, true) {
|
||||
t.Errorf("\nExpecting <true>,\n Received <%+v>", shouldRun)
|
||||
}
|
||||
rld := srv2.Reload()
|
||||
if rld != nil {
|
||||
t.Errorf("\nExpecting <nil>,\n Received <%+v>", rld)
|
||||
}
|
||||
getCoreS := srv2.GetCoreS()
|
||||
if getCoreS == nil {
|
||||
t.Errorf("\nExpecting not <nil>,\n Received <%+v>", getCoreS)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ func TestKamailioAgentReload(t *testing.T) {
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Expecting OK ,received %s", reply)
|
||||
}
|
||||
|
||||
runtime.Gosched()
|
||||
time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// the engine should be stoped as we could not connect to kamailio
|
||||
|
||||
Reference in New Issue
Block a user