mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Moved Coverage tests from integration test files to their own
This commit is contained in:
committed by
Dan Christian Bogos
parent
0b4010eb14
commit
ac3b788e69
@@ -23,7 +23,6 @@ package dispatchers
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
@@ -643,184 +642,3 @@ func testDspAttrPingNoArgDispatcher(t *testing.T) {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1PingError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrEvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(cgrEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1PingErrorTenant(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrEvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: nil,
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(cgrEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1PingErrorAttributeSConns(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrEvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "ID",
|
||||
Time: nil,
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(cgrEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
var reply *engine.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventErrorTenant(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
var reply *engine.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventErrorAttributeS(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
|
||||
var reply *engine.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1ProcessEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
|
||||
var reply *engine.AttrSProcessEventReply
|
||||
err := dspSrv.AttributeSv1ProcessEvent(processEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1ProcessEventErrorAttributeSConns(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
|
||||
var reply *engine.AttrSProcessEventReply
|
||||
err := dspSrv.AttributeSv1ProcessEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
209
dispatchers/attributes_test.go
Normal file
209
dispatchers/attributes_test.go
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspAttributeSv1PingError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrEvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(cgrEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1PingErrorTenant(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrEvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: nil,
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(cgrEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1PingErrorAttributeSConns(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrEvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "ID",
|
||||
Time: nil,
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
err := dspSrv.AttributeSv1Ping(cgrEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
var reply *engine.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventErrorTenant(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
var reply *engine.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventErrorAttributeS(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
|
||||
var reply *engine.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1ProcessEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
|
||||
var reply *engine.AttrSProcessEventReply
|
||||
err := dspSrv.AttributeSv1ProcessEvent(processEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1ProcessEventErrorAttributeSConns(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
processEvent := &engine.AttrArgsProcessEvent{
|
||||
AttributeIDs: nil,
|
||||
Context: nil,
|
||||
ProcessRuns: nil,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
|
||||
var reply *engine.AttrSProcessEventReply
|
||||
err := dspSrv.AttributeSv1ProcessEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/ltcache"
|
||||
@@ -385,456 +383,3 @@ func testDspChcClear(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PingError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PingErrorArgs(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PingErrorAttributeSConns(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemIDsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemIDsWithAPIOpts{}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetItemIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemIDsErrorArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetItemIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasItemError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasItem(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasItemErrorArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasItem(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemExpiryTimeCacheSv1GetItemExpiryTimeError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
|
||||
var reply *time.Time
|
||||
result := dspSrv.CacheSv1GetItemExpiryTime(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemExpiryTimeCacheSv1GetItemExpiryTimeErrorArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *time.Time
|
||||
result := dspSrv.CacheSv1GetItemExpiryTime(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItem(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItem(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItems(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemsArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItems(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ClearError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Clear(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ClearArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Clear(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetCacheStatsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
|
||||
var reply *map[string]*ltcache.CacheStats
|
||||
result := dspSrv.CacheSv1GetCacheStats(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetCacheStatsArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]*ltcache.CacheStats
|
||||
result := dspSrv.CacheSv1GetCacheStats(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PrecacheStatusError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.CacheSv1PrecacheStatus(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PrecacheStatusArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.CacheSv1PrecacheStatus(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasGroupError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasGroup(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasGroupArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasGroup(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetGroupItemIDsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetGroupItemIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetGroupItemIDsArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetGroupItemIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveGroupError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveGroup(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveGroupArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveGroup(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReloadCacheError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReloadCache(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReloadCacheNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReloadCache(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1LoadCacheError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1LoadCache(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1LoadCacheNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1LoadCache(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateRemoveError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgCacheReplicateRemove{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateRemove(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateRemoveNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgCacheReplicateRemove{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateRemove(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateSetError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgCacheReplicateSet{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateSet(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateSetNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgCacheReplicateSet{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateSet(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
481
dispatchers/caches_test.go
Normal file
481
dispatchers/caches_test.go
Normal file
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/ltcache"
|
||||
)
|
||||
|
||||
func TestDspCacheSv1PingError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PingErrorArgs(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PingErrorAttributeSConns(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemIDsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemIDsWithAPIOpts{}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetItemIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemIDsErrorArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetItemIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasItemError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasItem(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasItemErrorArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasItem(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemExpiryTimeCacheSv1GetItemExpiryTimeError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
|
||||
var reply *time.Time
|
||||
result := dspSrv.CacheSv1GetItemExpiryTime(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItemExpiryTimeCacheSv1GetItemExpiryTimeErrorArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *time.Time
|
||||
result := dspSrv.CacheSv1GetItemExpiryTime(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItem(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItem(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItems(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveItemsArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveItems(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ClearError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Clear(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ClearArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1Clear(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetCacheStatsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
|
||||
var reply *map[string]*ltcache.CacheStats
|
||||
result := dspSrv.CacheSv1GetCacheStats(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetCacheStatsArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]*ltcache.CacheStats
|
||||
result := dspSrv.CacheSv1GetCacheStats(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PrecacheStatusError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.CacheSv1PrecacheStatus(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1PrecacheStatusArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrCacheIDsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.CacheSv1PrecacheStatus(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasGroupError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasGroup(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1HasGroupArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *bool
|
||||
result := dspSrv.CacheSv1HasGroup(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetGroupItemIDsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetGroupItemIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetGroupItemIDsArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.CacheSv1GetGroupItemIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveGroupError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveGroup(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1RemoveGroupArgsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgsGetGroupWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1RemoveGroup(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReloadCacheError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReloadCache(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReloadCacheNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReloadCache(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1LoadCacheError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1LoadCache(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1LoadCacheNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1LoadCache(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateRemoveError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgCacheReplicateRemove{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateRemove(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateRemoveNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgCacheReplicateRemove{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateRemove(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateSetError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.ArgCacheReplicateSet{}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateSet(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1ReplicateSetNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.ArgCacheReplicateSet{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CacheSv1ReplicateSet(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -639,327 +638,3 @@ func testDspCDRsV2StoreSessionCostNoAuth(t *testing.T) {
|
||||
t.Error("Unexpected error: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1PingError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1PingNilError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{}
|
||||
var reply *[]*engine.CDR
|
||||
result := dspSrv.CDRsV1GetCDRs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.CDR
|
||||
result := dspSrv.CDRsV1GetCDRs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsCountError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{}
|
||||
var reply *int64
|
||||
result := dspSrv.CDRsV1GetCDRsCount(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsCountNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int64
|
||||
result := dspSrv.CDRsV1GetCDRsCount(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1RateCDRsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgRateCDRs{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1RateCDRs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1RateCDRsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgRateCDRs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1RateCDRs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessExternalCDRError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ExternalCDRWithAPIOpts{
|
||||
ExternalCDR: &engine.ExternalCDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessExternalCDR(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessExternalCDRNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ExternalCDRWithAPIOpts{
|
||||
ExternalCDR: &engine.ExternalCDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessExternalCDR(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessCDRError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CDRWithAPIOpts{
|
||||
CDR: &engine.CDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessCDR(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessCDRNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CDRWithAPIOpts{
|
||||
CDR: &engine.CDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessCDR(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2ProcessEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
Flags: nil,
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]*utils.EventWithFlags
|
||||
result := dspSrv.CDRsV2ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
Flags: nil,
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]*utils.EventWithFlags
|
||||
result := dspSrv.CDRsV2ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
Flags: nil,
|
||||
CGREvent: utils.CGREvent{},
|
||||
}
|
||||
var reply *[]*utils.EventWithFlags
|
||||
result := dspSrv.CDRsV2ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1StoreSessionCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.AttrCDRSStoreSMCost{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1StoreSessionCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1StoreSessionCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.AttrCDRSStoreSMCost{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1StoreSessionCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2StoreSessionCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgsV2CDRSStoreSMCost{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV2StoreSessionCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2StoreSessionCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgsV2CDRSStoreSMCost{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV2StoreSessionCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
351
dispatchers/cdrs_test.go
Normal file
351
dispatchers/cdrs_test.go
Normal file
@@ -0,0 +1,351 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspCDRsV1PingError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1PingNilError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{}
|
||||
var reply *[]*engine.CDR
|
||||
result := dspSrv.CDRsV1GetCDRs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.CDR
|
||||
result := dspSrv.CDRsV1GetCDRs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsCountError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{}
|
||||
var reply *int64
|
||||
result := dspSrv.CDRsV1GetCDRsCount(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1GetCDRsCountNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.RPCCDRsFilterWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int64
|
||||
result := dspSrv.CDRsV1GetCDRsCount(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1RateCDRsError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgRateCDRs{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1RateCDRs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1RateCDRsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgRateCDRs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1RateCDRs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessExternalCDRError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ExternalCDRWithAPIOpts{
|
||||
ExternalCDR: &engine.ExternalCDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessExternalCDR(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessExternalCDRNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ExternalCDRWithAPIOpts{
|
||||
ExternalCDR: &engine.ExternalCDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessExternalCDR(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessCDRError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CDRWithAPIOpts{
|
||||
CDR: &engine.CDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessCDR(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1ProcessCDRNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CDRWithAPIOpts{
|
||||
CDR: &engine.CDR{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1ProcessCDR(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2ProcessEventError(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
Flags: nil,
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]*utils.EventWithFlags
|
||||
result := dspSrv.CDRsV2ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
Flags: nil,
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]*utils.EventWithFlags
|
||||
result := dspSrv.CDRsV2ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgV1ProcessEvent{
|
||||
Flags: nil,
|
||||
CGREvent: utils.CGREvent{},
|
||||
}
|
||||
var reply *[]*utils.EventWithFlags
|
||||
result := dspSrv.CDRsV2ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1StoreSessionCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.AttrCDRSStoreSMCost{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1StoreSessionCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV1StoreSessionCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.AttrCDRSStoreSMCost{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV1StoreSessionCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2StoreSessionCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgsV2CDRSStoreSMCost{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV2StoreSessionCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCDRsV2StoreSessionCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgsV2CDRSStoreSMCost{}
|
||||
var reply *string
|
||||
result := dspSrv.CDRsV2StoreSessionCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -307,95 +305,3 @@ func testDspCppGetChtgRoundRobin(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDspChargerSv1PingNilStruct(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
result := dspSrv.ChargerSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ChargerSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.ChargerSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1GetChargersForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *engine.ChargerProfiles
|
||||
result := dspSrv.ChargerSv1GetChargersForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1GetChargersForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *engine.ChargerProfiles
|
||||
result := dspSrv.ChargerSv1GetChargersForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.ChrgSProcessEventReply
|
||||
result := dspSrv.ChargerSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *[]*engine.ChrgSProcessEventReply
|
||||
result := dspSrv.ChargerSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
119
dispatchers/chargers_test.go
Normal file
119
dispatchers/chargers_test.go
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspChargerSv1PingNilStruct(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
result := dspSrv.ChargerSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ChargerSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.ChargerSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1GetChargersForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *engine.ChargerProfiles
|
||||
result := dspSrv.ChargerSv1GetChargersForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1GetChargersForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *engine.ChargerProfiles
|
||||
result := dspSrv.ChargerSv1GetChargersForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.ChrgSProcessEventReply
|
||||
result := dspSrv.ChargerSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspChargerSv1ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *[]*engine.ChrgSProcessEventReply
|
||||
result := dspSrv.ChargerSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -84,138 +84,3 @@ func testDspConfigSv1GetJSONSection(t *testing.T) {
|
||||
t.Errorf("Expected: %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1GetConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SectionWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.ConfigSv1GetConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1GetConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SectionWithAPIOpts{}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.ConfigSv1GetConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1ReloadConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.ReloadArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1ReloadConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1ReloadConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.ReloadArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1ReloadConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SetConfigArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SetConfigArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigFromJSONNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SetConfigFromJSONArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfigFromJSON(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigFromJSONErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SetConfigFromJSONArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfigFromJSON(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1GetConfigAsJSONNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SectionWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1GetConfigAsJSON(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1GetConfigAsJSONErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SectionWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1GetConfigAsJSON(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
160
dispatchers/config_test.go
Normal file
160
dispatchers/config_test.go
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
)
|
||||
|
||||
func TestDspConfigSv1GetConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SectionWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.ConfigSv1GetConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1GetConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SectionWithAPIOpts{}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.ConfigSv1GetConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1ReloadConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.ReloadArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1ReloadConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1ReloadConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.ReloadArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1ReloadConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SetConfigArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SetConfigArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigFromJSONNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SetConfigFromJSONArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfigFromJSON(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1SetConfigFromJSONErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SetConfigFromJSONArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1SetConfigFromJSON(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1GetConfigAsJSONNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &config.SectionWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1GetConfigAsJSON(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspConfigSv1GetConfigAsJSONErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &config.SectionWithAPIOpts{}
|
||||
var reply *string
|
||||
result := dspSrv.ConfigSv1GetConfigAsJSON(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
@@ -106,84 +105,3 @@ func testDspCoreLoad(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDspCoreSv1StatusNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1StatusErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.DurationArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.DurationArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
107
dispatchers/core_test.go
Normal file
107
dispatchers/core_test.go
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspCoreSv1StatusNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1StatusErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.DurationArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.DurationArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
3070
dispatchers/replicator_test.go
Normal file
3070
dispatchers/replicator_test.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -24,8 +24,6 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -319,242 +317,3 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDspResourceSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourcesForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resources
|
||||
result := dspSrv.ResourceSv1GetResourcesForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourcesForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resources
|
||||
result := dspSrv.ResourceSv1GetResourcesForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AuthorizeResourcesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AuthorizeResources(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AuthorizeResourcesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AuthorizeResources(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1ReleaseResourcesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1ReleaseResources(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1ReleaseResourcesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1ReleaseResources(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resource
|
||||
result := dspSrv.ResourceSv1GetResource(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resource
|
||||
result := dspSrv.ResourceSv1GetResource(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AllocateResourcesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AllocateResources(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AllocateResourcesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AllocateResources(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceWithConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.ResourceWithConfig
|
||||
result := dspSrv.ResourceSv1GetResourceWithConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceWithConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.ResourceWithConfig
|
||||
result := dspSrv.ResourceSv1GetResourceWithConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
266
dispatchers/resources_test.go
Normal file
266
dispatchers/resources_test.go
Normal file
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspResourceSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourcesForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resources
|
||||
result := dspSrv.ResourceSv1GetResourcesForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourcesForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resources
|
||||
result := dspSrv.ResourceSv1GetResourcesForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AuthorizeResourcesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AuthorizeResources(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AuthorizeResourcesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AuthorizeResources(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1ReleaseResourcesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1ReleaseResources(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1ReleaseResourcesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1ReleaseResources(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resource
|
||||
result := dspSrv.ResourceSv1GetResource(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Resource
|
||||
result := dspSrv.ResourceSv1GetResource(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AllocateResourcesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AllocateResources(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1AllocateResourcesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResourceSv1AllocateResources(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceWithConfigNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.ResourceWithConfig
|
||||
result := dspSrv.ResourceSv1GetResourceWithConfig(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResourceSv1GetResourceWithConfigErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.ResourceWithConfig
|
||||
result := dspSrv.ResourceSv1GetResourceWithConfig(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
@@ -242,271 +238,3 @@ func testDspResponderInternal(t *testing.T) {
|
||||
t.Errorf("Expected: DispatcherS1 , received: %s", strRply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderPingEventNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderPing(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderPingEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderPing(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderPingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderPing(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderDebitNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderDebit(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderDebitErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderDebit(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderGetCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderGetCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderMaxDebitNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderMaxDebit(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderMaxDebitErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderMaxDebit(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundIncrementsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Account
|
||||
result := dspSrv.ResponderRefundIncrements(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundIncrementsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Account
|
||||
result := dspSrv.ResponderRefundIncrements(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundRoundingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *float64
|
||||
result := dspSrv.ResponderRefundRounding(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundRoundingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *float64
|
||||
result := dspSrv.ResponderRefundRounding(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetMaxSessionTimeNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *time.Duration
|
||||
result := dspSrv.ResponderGetMaxSessionTime(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetMaxSessionTimeErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *time.Duration
|
||||
result := dspSrv.ResponderGetMaxSessionTime(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderShutdownNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderShutdown(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderShutdownErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderShutdown(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
296
dispatchers/responder_test.go
Normal file
296
dispatchers/responder_test.go
Normal file
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspResponderPingEventNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderPing(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderPingEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderPing(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderPingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderPing(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderDebitNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderDebit(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderDebitErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderDebit(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderGetCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderGetCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderMaxDebitNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderMaxDebit(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderMaxDebitErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.CallCost
|
||||
result := dspSrv.ResponderMaxDebit(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundIncrementsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Account
|
||||
result := dspSrv.ResponderRefundIncrements(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundIncrementsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Account
|
||||
result := dspSrv.ResponderRefundIncrements(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundRoundingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *float64
|
||||
result := dspSrv.ResponderRefundRounding(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderRefundRoundingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *float64
|
||||
result := dspSrv.ResponderRefundRounding(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetMaxSessionTimeNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *time.Duration
|
||||
result := dspSrv.ResponderGetMaxSessionTime(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetMaxSessionTimeErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.CallDescriptorWithAPIOpts{
|
||||
CallDescriptor: &engine.CallDescriptor{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *time.Duration
|
||||
result := dspSrv.ResponderGetMaxSessionTime(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderShutdownNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderShutdown(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderShutdownErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ResponderShutdown(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -417,139 +415,3 @@ func testDspSupGetSupplierForEvent(t *testing.T) {
|
||||
t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(supProf))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.RouteSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.RouteSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.RouteSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.SortedRoutesList
|
||||
result := dspSrv.RouteSv1GetRoutes(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.SortedRoutesList
|
||||
result := dspSrv.RouteSv1GetRoutes(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesListNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.RouteSv1GetRoutesList(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesListErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.RouteSv1GetRoutesList(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRouteProfilesForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.RouteProfile
|
||||
result := dspSrv.RouteSv1GetRouteProfilesForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRouteProfilesForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.RouteProfile
|
||||
result := dspSrv.RouteSv1GetRouteProfilesForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
163
dispatchers/routes_test.go
Normal file
163
dispatchers/routes_test.go
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspRouteSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.RouteSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.RouteSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.RouteSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.SortedRoutesList
|
||||
result := dspSrv.RouteSv1GetRoutes(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.SortedRoutesList
|
||||
result := dspSrv.RouteSv1GetRoutes(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesListNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.RouteSv1GetRoutesList(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRoutesListErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ArgsGetRoutes{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.RouteSv1GetRoutesList(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRouteProfilesForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.RouteProfile
|
||||
result := dspSrv.RouteSv1GetRouteProfilesForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspRouteSv1GetRouteProfilesForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*engine.RouteProfile
|
||||
result := dspSrv.RouteSv1GetRouteProfilesForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,6 @@ package dispatchers
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
@@ -79,131 +77,3 @@ func testDspSchedPing(t *testing.T) {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1PingErrorNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ReloadErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Reload(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ReloadPingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Reload(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrsExecuteActions{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrsExecuteActions{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionPlansErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrsExecuteActionPlans{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActionPlans(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionPlansNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrsExecuteActionPlans{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActionPlans(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
154
dispatchers/scheduler_test.go
Normal file
154
dispatchers/scheduler_test.go
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspSchedulerSv1PingErrorNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ReloadErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Reload(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ReloadPingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1Reload(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrsExecuteActions{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrsExecuteActions{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionPlansErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.AttrsExecuteActionPlans{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActionPlans(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSchedulerSv1ExecuteActionPlansNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.AttrsExecuteActionPlans{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SchedulerSv1ExecuteActionPlans(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/sessions"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -1054,698 +1053,3 @@ func testDspSessionSTIRIdentity(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReply
|
||||
result := dspSrv.SessionSv1AuthorizeEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReply
|
||||
result := dspSrv.SessionSv1AuthorizeEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventWithDigestNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReplyWithDigest
|
||||
result := dspSrv.SessionSv1AuthorizeEventWithDigest(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventWithDigestErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReplyWithDigest
|
||||
result := dspSrv.SessionSv1AuthorizeEventWithDigest(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitSessionReply
|
||||
result := dspSrv.SessionSv1InitiateSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitSessionReply
|
||||
result := dspSrv.SessionSv1InitiateSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionWithDigestNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitReplyWithDigest
|
||||
result := dspSrv.SessionSv1InitiateSessionWithDigest(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionWithDigestErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitReplyWithDigest
|
||||
result := dspSrv.SessionSv1InitiateSessionWithDigest(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1UpdateSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1UpdateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1UpdateSessionReply
|
||||
result := dspSrv.SessionSv1UpdateSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1UpdateSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1UpdateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1UpdateSessionReply
|
||||
result := dspSrv.SessionSv1UpdateSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SyncSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SyncSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SyncSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SyncSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1TerminateSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1TerminateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1TerminateSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1TerminateSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1TerminateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1TerminateSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessCDRNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ProcessCDR(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessCDRErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ProcessCDR(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessMessageNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1ProcessMessageArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessMessageReply
|
||||
result := dspSrv.SessionSv1ProcessMessage(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessMessageErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1ProcessMessageArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessMessageReply
|
||||
result := dspSrv.SessionSv1ProcessMessage(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessEventReply
|
||||
result := dspSrv.SessionSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessEventReply
|
||||
result := dspSrv.SessionSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1GetCostReply
|
||||
result := dspSrv.SessionSv1GetCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1GetCostReply
|
||||
result := dspSrv.SessionSv1GetCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetActiveSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetActiveSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsCountNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetActiveSessionsCount(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsCountErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetActiveSessionsCount(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ForceDisconnectNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ForceDisconnect(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ForceDisconnectErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ForceDisconnect(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetPassiveSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetPassiveSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ReplicateSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := ArgsReplicateSessionsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ReplicateSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ReplicateSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := ArgsReplicateSessionsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ReplicateSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsCountNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetPassiveSessionsCount(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsCountErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetPassiveSessionsCount(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SetPassiveSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.Session{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SetPassiveSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SetPassiveSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.Session{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SetPassiveSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ActivateSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ActivateSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ActivateSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ActivateSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1DeactivateSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1DeactivateSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1DeactivateSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1DeactivateSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRAuthenticateNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1STIRAuthenticateArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRAuthenticate(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRAuthenticateErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1STIRAuthenticateArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRAuthenticate(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRIdentityNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1STIRIdentityArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRIdentity(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRIdentityErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1STIRIdentityArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRIdentity(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
722
dispatchers/sessions_test.go
Normal file
722
dispatchers/sessions_test.go
Normal file
@@ -0,0 +1,722 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/sessions"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspSessionSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReply
|
||||
result := dspSrv.SessionSv1AuthorizeEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReply
|
||||
result := dspSrv.SessionSv1AuthorizeEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventWithDigestNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReplyWithDigest
|
||||
result := dspSrv.SessionSv1AuthorizeEventWithDigest(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1AuthorizeEventWithDigestErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1AuthorizeArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1AuthorizeReplyWithDigest
|
||||
result := dspSrv.SessionSv1AuthorizeEventWithDigest(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitSessionReply
|
||||
result := dspSrv.SessionSv1InitiateSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitSessionReply
|
||||
result := dspSrv.SessionSv1InitiateSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionWithDigestNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitReplyWithDigest
|
||||
result := dspSrv.SessionSv1InitiateSessionWithDigest(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1InitiateSessionWithDigestErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1InitSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1InitReplyWithDigest
|
||||
result := dspSrv.SessionSv1InitiateSessionWithDigest(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1UpdateSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1UpdateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1UpdateSessionReply
|
||||
result := dspSrv.SessionSv1UpdateSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1UpdateSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1UpdateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1UpdateSessionReply
|
||||
result := dspSrv.SessionSv1UpdateSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SyncSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SyncSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SyncSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SyncSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1TerminateSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1TerminateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1TerminateSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1TerminateSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1TerminateSessionArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1TerminateSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessCDRNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ProcessCDR(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessCDRErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ProcessCDR(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessMessageNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1ProcessMessageArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessMessageReply
|
||||
result := dspSrv.SessionSv1ProcessMessage(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessMessageErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1ProcessMessageArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessMessageReply
|
||||
result := dspSrv.SessionSv1ProcessMessage(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessEventReply
|
||||
result := dspSrv.SessionSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1ProcessEventReply
|
||||
result := dspSrv.SessionSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetCostNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1GetCostReply
|
||||
result := dspSrv.SessionSv1GetCost(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetCostErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1ProcessEventArgs{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *sessions.V1GetCostReply
|
||||
result := dspSrv.SessionSv1GetCost(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetActiveSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetActiveSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsCountNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetActiveSessionsCount(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetActiveSessionsCountErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetActiveSessionsCount(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ForceDisconnectNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ForceDisconnect(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ForceDisconnectErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ForceDisconnect(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetPassiveSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]*sessions.ExternalSession
|
||||
result := dspSrv.SessionSv1GetPassiveSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ReplicateSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := ArgsReplicateSessionsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ReplicateSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ReplicateSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := ArgsReplicateSessionsWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ReplicateSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsCountNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetPassiveSessionsCount(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1GetPassiveSessionsCountErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionFilter{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *int
|
||||
result := dspSrv.SessionSv1GetPassiveSessionsCount(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SetPassiveSessionNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.Session{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SetPassiveSession(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1SetPassiveSessionErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.Session{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1SetPassiveSession(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ActivateSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ActivateSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1ActivateSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1ActivateSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1DeactivateSessionsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1DeactivateSessions(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1DeactivateSessionsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1DeactivateSessions(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRAuthenticateNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1STIRAuthenticateArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRAuthenticate(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRAuthenticateErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1STIRAuthenticateArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRAuthenticate(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRIdentityNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &sessions.V1STIRIdentityArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRIdentity(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspSessionSv1STIRIdentityErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &sessions.V1STIRIdentityArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.SessionSv1STIRIdentity(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -362,205 +360,3 @@ func testDspStsTestAuthKey3(t *testing.T) {
|
||||
t.Errorf("expecting: %+v, received reply: %v", estats, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.StatSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.StatSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.StatSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetStatQueuesForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetStatQueuesForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetStatQueuesForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetStatQueuesForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueStringMetricsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.StatSv1GetQueueStringMetrics(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueStringMetricsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.StatSv1GetQueueStringMetrics(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueFloatMetricsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]float64
|
||||
result := dspSrv.StatSv1GetQueueFloatMetrics(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueFloatMetricsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]float64
|
||||
result := dspSrv.StatSv1GetQueueFloatMetrics(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueIDsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetQueueIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueIDsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetQueueIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
229
dispatchers/stats_test.go
Normal file
229
dispatchers/stats_test.go
Normal file
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspStatSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.StatSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
var reply *string
|
||||
result := dspSrv.StatSv1Ping(nil, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.StatSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetStatQueuesForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetStatQueuesForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetStatQueuesForEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetStatQueuesForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueStringMetricsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.StatSv1GetQueueStringMetrics(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueStringMetricsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]string
|
||||
result := dspSrv.StatSv1GetQueueStringMetrics(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1ProcessEventErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.StatsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueFloatMetricsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]float64
|
||||
result := dspSrv.StatSv1GetQueueFloatMetrics(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueFloatMetricsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *map[string]float64
|
||||
result := dspSrv.StatSv1GetQueueFloatMetrics(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueIDsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetQueueIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspStatSv1GetQueueIDsErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.StatSv1GetQueueIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -265,169 +263,3 @@ func testDspThTestAuthKey3(t *testing.T) {
|
||||
t.Errorf("expecting: %+v, received: %+v", eIDs, ids)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
result := dspSrv.ThresholdSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ThresholdSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.ThresholdSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdsForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Thresholds
|
||||
result := dspSrv.ThresholdSv1GetThresholdsForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdsEvnil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Thresholds
|
||||
result := dspSrv.ThresholdSv1GetThresholdsForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1ProcessEventnNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdIDsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1GetThresholdIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdIDErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1GetThresholdIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Threshold
|
||||
result := dspSrv.ThresholdSv1GetThreshold(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Threshold
|
||||
result := dspSrv.ThresholdSv1GetThreshold(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
193
dispatchers/thresholds_test.go
Normal file
193
dispatchers/thresholds_test.go
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspThresholdSv1PingNilEvent(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
var reply *string
|
||||
result := dspSrv.ThresholdSv1Ping(nil, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.ThresholdSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.ThresholdSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdsForEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Thresholds
|
||||
result := dspSrv.ThresholdSv1GetThresholdsForEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdsEvnil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Thresholds
|
||||
result := dspSrv.ThresholdSv1GetThresholdsForEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1ProcessEventNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1ProcessEventnNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &engine.ThresholdsArgsProcessEvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1ProcessEvent(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdIDsNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1GetThresholdIDs(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdIDErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *[]string
|
||||
result := dspSrv.ThresholdSv1GetThresholdIDs(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Threshold
|
||||
result := dspSrv.ThresholdSv1GetThreshold(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspThresholdSv1GetThresholdErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "tenant",
|
||||
},
|
||||
}
|
||||
var reply *engine.Threshold
|
||||
result := dspSrv.ThresholdSv1GetThreshold(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user