mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated tests after API rename
This commit is contained in:
committed by
Dan Christian Bogos
parent
7040a0fab7
commit
be06504663
@@ -241,6 +241,9 @@ func testDiamItDryRun(t *testing.T) {
|
||||
// ============================================
|
||||
// prevent nil pointer dereference
|
||||
// ============================================
|
||||
if diamClnt == nil {
|
||||
t.Fatal("Diameter client should not be nil")
|
||||
}
|
||||
if diamClnt.conn == nil {
|
||||
t.Fatal("Diameter conection should not be nil")
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func testV2CDRsLoadTariffPlanFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV2CDRsProcessCDR(t *testing.T) {
|
||||
args := &engine.ArgV2ProcessCDR{
|
||||
args := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
@@ -141,7 +141,7 @@ func testV2CDRsProcessCDR(t *testing.T) {
|
||||
}
|
||||
|
||||
var reply string
|
||||
if err := cdrsRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := cdrsRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
@@ -219,8 +219,10 @@ func testV2CDRsRateCDRs(t *testing.T) {
|
||||
} else if reply != "OK" {
|
||||
t.Error("Calling ApierV1.SetRatingProfile got reply: ", reply)
|
||||
}
|
||||
if err := cdrsRpc.Call(utils.CDRsV1RateCDRs,
|
||||
&utils.RPCCDRsFilter{NotRunIDs: []string{utils.MetaRaw}}, &reply); err != nil {
|
||||
if err := cdrsRpc.Call(utils.CDRsV1RateCDRs, &engine.ArgRateCDRs{
|
||||
RPCCDRsFilter: utils.RPCCDRsFilter{NotRunIDs: []string{utils.MetaRaw}},
|
||||
ChargerS: utils.BoolPointer(true),
|
||||
}, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
@@ -270,7 +272,7 @@ func testV2CDRsGetCdrs2(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV2CDRsUsageNegative(t *testing.T) {
|
||||
argsCdr := &engine.ArgV2ProcessCDR{
|
||||
argsCdr := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
@@ -290,7 +292,7 @@ func testV2CDRsUsageNegative(t *testing.T) {
|
||||
},
|
||||
}
|
||||
var reply string
|
||||
if err := cdrsRpc.Call(utils.CDRsV2ProcessCDR, argsCdr, &reply); err != nil {
|
||||
if err := cdrsRpc.Call(utils.CDRsV1ProcessEvent, argsCdr, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
|
||||
@@ -303,7 +303,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tPrfl, thReply)
|
||||
}
|
||||
|
||||
args := &engine.ArgV2ProcessCDR{
|
||||
args := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
@@ -321,7 +321,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) {
|
||||
},
|
||||
}
|
||||
//process cdr should trigger balance update event
|
||||
if err := cdrsOfflineRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := cdrsOfflineRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
|
||||
@@ -184,7 +184,6 @@ func cdrLogAction(acc *Account, a *Action, acs Actions, extraData interface{}) (
|
||||
OriginID: utils.GenUUID(),
|
||||
ExtraFields: make(map[string]string),
|
||||
PreRated: true,
|
||||
CostDetails: NewBareEventCost(),
|
||||
}
|
||||
cdr.CGRID = utils.Sha1(cdr.OriginID, cdr.SetupTime.String())
|
||||
cdr.Usage = time.Duration(1)
|
||||
|
||||
@@ -20,7 +20,6 @@ package engine
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -392,20 +391,18 @@ func (cbs Accounting) Clone() (cln Accounting) {
|
||||
|
||||
// IfaceAsEventCost converts an interface to EventCost
|
||||
func IfaceAsEventCost(itm interface{}) (ec *EventCost, err error) {
|
||||
switch itm.(type) {
|
||||
switch otm := itm.(type) {
|
||||
case nil:
|
||||
case *EventCost:
|
||||
ec = itm.(*EventCost)
|
||||
ec = otm
|
||||
case string:
|
||||
ecStr, canCast := itm.(string)
|
||||
if !canCast {
|
||||
return nil, errors.New("cannot cast to string")
|
||||
}
|
||||
var rawEC EventCost
|
||||
if errUnmarshal := json.Unmarshal([]byte(ecStr), &rawEC); errUnmarshal != nil {
|
||||
if errUnmarshal := json.Unmarshal([]byte(otm), &rawEC); errUnmarshal != nil {
|
||||
return nil, fmt.Errorf("JSON cannot unmarshal to *EventCost, err: %s", errUnmarshal.Error())
|
||||
}
|
||||
ec = &rawEC
|
||||
case map[string]interface{}:
|
||||
ec, err = IfaceAsEventCost(utils.ToJSON(otm))
|
||||
default:
|
||||
err = utils.ErrNotConvertibleNoCaps
|
||||
}
|
||||
|
||||
@@ -139,8 +139,8 @@ func testCDREProcessCdr(t *testing.T) {
|
||||
ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}
|
||||
cdr.ComputeCGRID()
|
||||
var reply string
|
||||
if err := cdreRPC.Call(utils.CDRsV2ProcessCDR,
|
||||
&engine.ArgV2ProcessCDR{CGREvent: *cdr.AsCGREvent()}, &reply); err != nil {
|
||||
if err := cdreRPC.Call(utils.CDRsV1ProcessEvent,
|
||||
&engine.ArgV1ProcessEvent{CGREvent: *cdr.AsCGREvent()}, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
|
||||
@@ -131,7 +131,7 @@ func testV2CDRsLoadTariffPlanFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV2CDRsProcessCDR(t *testing.T) {
|
||||
args := &engine.ArgV2ProcessCDR{
|
||||
args := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
@@ -152,7 +152,7 @@ func testV2CDRsProcessCDR(t *testing.T) {
|
||||
}
|
||||
|
||||
var reply string
|
||||
if err := cdrsRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := cdrsRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
@@ -201,7 +201,7 @@ func testV2CDRsGetCdrs(t *testing.T) {
|
||||
|
||||
//Disable Attributes process
|
||||
func testV2CDRsProcessCDR2(t *testing.T) {
|
||||
args := &engine.ArgV2ProcessCDR{
|
||||
args := &engine.ArgV1ProcessEvent{
|
||||
AttributeS: utils.BoolPointer(false),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
@@ -223,7 +223,7 @@ func testV2CDRsProcessCDR2(t *testing.T) {
|
||||
}
|
||||
|
||||
var reply string
|
||||
if err := cdrsRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := cdrsRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
@@ -274,7 +274,7 @@ func testV2CDRsGetCdrs2(t *testing.T) {
|
||||
|
||||
//Disable Attributes and Charger process
|
||||
func testV2CDRsProcessCDR3(t *testing.T) {
|
||||
args := &engine.ArgV2ProcessCDR{
|
||||
args := &engine.ArgV1ProcessEvent{
|
||||
AttributeS: utils.BoolPointer(false),
|
||||
ChargerS: utils.BoolPointer(false),
|
||||
CGREvent: utils.CGREvent{
|
||||
@@ -297,7 +297,7 @@ func testV2CDRsProcessCDR3(t *testing.T) {
|
||||
}
|
||||
|
||||
var reply string
|
||||
if err := cdrsRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := cdrsRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
|
||||
@@ -152,8 +152,8 @@ func TestCDRsOnExpHttpCdrReplication(t *testing.T) {
|
||||
PreRated: true,
|
||||
}
|
||||
var reply string
|
||||
if err := cdrsMasterRpc.Call(utils.CDRsV2ProcessCDR,
|
||||
&engine.ArgV2ProcessCDR{CGREvent: *testCdr1.AsCGREvent()}, &reply); err != nil {
|
||||
if err := cdrsMasterRpc.Call(utils.CDRsV1ProcessEvent,
|
||||
&engine.ArgV1ProcessEvent{CGREvent: *testCdr1.AsCGREvent()}, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
@@ -275,8 +275,8 @@ func TestCDRsOnExpAMQPReplication(t *testing.T) {
|
||||
PreRated: true,
|
||||
}
|
||||
var reply string
|
||||
if err := cdrsMasterRpc.Call(utils.CDRsV2ProcessCDR,
|
||||
&engine.ArgV2ProcessCDR{CGREvent: *testCdr.AsCGREvent()}, &reply); err != nil {
|
||||
if err := cdrsMasterRpc.Call(utils.CDRsV1ProcessEvent,
|
||||
&engine.ArgV1ProcessEvent{CGREvent: *testCdr.AsCGREvent()}, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
|
||||
@@ -692,7 +692,7 @@ func testRPCMethodsCdrsProcessCDR(t *testing.T) {
|
||||
}
|
||||
|
||||
var reply string
|
||||
if err := rpcRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := rpcRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
@@ -709,7 +709,7 @@ func testRPCMethodsCdrsProcessCDR(t *testing.T) {
|
||||
//change originID so CGRID be different
|
||||
args.Event[utils.OriginID] = "testRPCMethodsProcessCDR2"
|
||||
// we should get response from cache
|
||||
if err := rpcRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := rpcRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
@@ -726,7 +726,7 @@ func testRPCMethodsCdrsProcessCDR(t *testing.T) {
|
||||
time.Sleep(1*time.Second + 500*time.Millisecond)
|
||||
//change originID so CGRID be different
|
||||
args.Event[utils.OriginID] = "testRPCMethodsProcessCDR3"
|
||||
if err := rpcRpc.Call(utils.CDRsV2ProcessCDR, args, &reply); err != nil {
|
||||
if err := rpcRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
|
||||
@@ -873,7 +873,7 @@ func TestSessionsVoiceSessionTTL(t *testing.T) {
|
||||
t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue())
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
eAcntVal = 4.0566
|
||||
eAcntVal = 4.0567 // rounding issue; old values : 4.0565 , 4.0566
|
||||
if err := sessionsRPC.Call("ApierV2.GetAccount", attrs, &acnt); err != nil {
|
||||
t.Error(err)
|
||||
} else if acnt.BalanceMap[utils.MONETARY].GetTotalValue() != eAcntVal {
|
||||
|
||||
Reference in New Issue
Block a user