Updated tests after latest changes

This commit is contained in:
Trial97
2019-03-22 19:55:23 +02:00
committed by Dan Christian Bogos
parent c3567208ed
commit 7040a0fab7
6 changed files with 24 additions and 6 deletions

View File

@@ -179,8 +179,13 @@ func testAccITDebitBalance(t *testing.T) {
func testAccITAddBalance(t *testing.T) {
var reply string
attrs := &AttrAddBalance{Tenant: "cgrates.org", Account: "testAccAddBalance",
BalanceType: "*monetary", Value: 1.5, Cdrlog: utils.BoolPointer(true)}
attrs := &AttrAddBalance{
Tenant: "cgrates.org",
Account: "testAccAddBalance",
BalanceType: "*monetary",
Value: 1.5,
Cdrlog: utils.BoolPointer(true),
}
if err := accRPC.Call("ApierV1.AddBalance", attrs, &reply); err != nil {
t.Error("Got error on ApierV1.AddBalance: ", err.Error())
} else if reply != "OK" {

View File

@@ -40,7 +40,8 @@ func (apier *ApierV1) GetEventCost(attrs utils.AttrGetCallCost, reply *engine.Ev
err = utils.NewErrServerError(err)
}
return err
} else if len(cdrs) == 0 {
} else if len(cdrs) == 0 ||
cdrs[0].CostDetails == nil { // to avoid nil pointer dereference
return utils.ErrNotFound
} else {
*reply = *cdrs[0].CostDetails

View File

@@ -279,6 +279,10 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) {
Items: 0,
Groups: 0,
},
utils.CacheClosedSessions: {
Items: 0,
Groups: 0,
},
}
if err := precacheRPC.Call(utils.CacheSv1GetCacheStats, cacheIDs, &reply); err != nil {
t.Error(err.Error())

View File

@@ -184,6 +184,7 @@ 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)

View File

@@ -364,5 +364,9 @@ func GetDefaultEmptyCacheStats() map[string]*ltcache.CacheStats {
Items: 0,
Groups: 0,
},
utils.CacheClosedSessions: {
Items: 0,
Groups: 0,
},
}
}

View File

@@ -142,11 +142,14 @@ func TestSessionsItTerminatUnexist(t *testing.T) {
}
var cdrs []*engine.ExternalCDR
req := utils.RPCCDRsFilter{DestinationPrefixes: []string{"1002"}}
req := utils.RPCCDRsFilter{
DestinationPrefixes: []string{"1002"},
RunIDs: []string{utils.MetaDefault},
}
if err := sItRPC.Call(utils.ApierV2GetCDRs, req, &cdrs); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if len(cdrs) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(cdrs))
t.Errorf("Unexpected number of CDRs returned: %v \n cdrs=%s", len(cdrs), utils.ToJSON(cdrs))
} else {
if cdrs[0].Usage != "2m0s" {
t.Errorf("Unexpected CDR Usage received, cdr: %v %+v ", cdrs[0].Usage, cdrs[0])
@@ -412,7 +415,7 @@ func TestSessionsItEventCostCompressing(t *testing.T) {
if err := sItRPC.Call(utils.ApierV1GetEventCost,
utils.AttrGetCallCost{CgrId: cgrID, RunId: utils.META_DEFAULT},
&ec); err != nil {
t.Error(err)
t.Fatal(err)
}
// make sure we only have one aggregated Charge
if len(ec.Charges) != 1 ||