mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added protection from panic to some integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
9bd35bfe1b
commit
97ff5fabc5
@@ -188,6 +188,13 @@ func testAttributeSGetAttributeForEvent(t *testing.T) {
|
||||
ev, &attrReply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if attrReply == nil {
|
||||
t.Errorf("Expecting attrReply to not be nil")
|
||||
// attrReply shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
attrReply.Compile() // Populate private variables in RSRParsers
|
||||
if !reflect.DeepEqual(eAttrPrf.Attributes[0].Substitute[0], attrReply.Attributes[0].Substitute[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eAttrPrf.Attributes[0].Substitute[0], attrReply.Attributes[0].Substitute[0])
|
||||
|
||||
@@ -381,6 +381,13 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if reply == nil {
|
||||
t.Errorf("Expecting reply to not be nil")
|
||||
// reply shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
reply.FilterIDs = []string{"TestFilter3"}
|
||||
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetThresholdProfile", reply, &result); err != nil {
|
||||
|
||||
@@ -150,6 +150,13 @@ func testV1RsGetResourcesForEvent(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
time.Sleep(time.Duration(500) * time.Millisecond)
|
||||
if reply == nil {
|
||||
t.Errorf("Expecting reply to not be nil")
|
||||
// reply shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
if len(*reply) != 1 {
|
||||
t.Errorf("Expecting: %+v, received: %+v", 1, len(*reply))
|
||||
}
|
||||
@@ -475,6 +482,13 @@ func testV1RsReleaseResource(t *testing.T) {
|
||||
} else if len(*rs) != 2 {
|
||||
t.Errorf("Resources: %+v", rs)
|
||||
}
|
||||
if rs == nil {
|
||||
t.Errorf("Expecting rs to not be nil")
|
||||
// rs shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
// make sure Resource1 have no more active resources
|
||||
for _, r := range *rs {
|
||||
if r.ID == "ResGroup1" &&
|
||||
@@ -518,6 +532,13 @@ func testV1RsDBStore(t *testing.T) {
|
||||
} else if len(*rs) != 2 {
|
||||
t.Errorf("Resources: %+v", rs)
|
||||
}
|
||||
if rs == nil {
|
||||
t.Errorf("Expecting rs to not be nil")
|
||||
// rs shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
// count resources before restart
|
||||
for _, r := range *rs {
|
||||
switch r.ID {
|
||||
|
||||
@@ -122,6 +122,13 @@ func TestTutITCacheStats(t *testing.T) {
|
||||
if err := tutLocalRpc.Call("ApierV1.GetCacheKeys", argsAPI, &rcvKeys); err != nil {
|
||||
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
|
||||
} else {
|
||||
if rcvKeys.DestinationIDs == nil {
|
||||
t.Errorf("Expecting rcvKeys.DestinationIDs to not be nil")
|
||||
// rcvKeys.DestinationIDs shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
if len(*expKeys.DestinationIDs) != len(*rcvKeys.DestinationIDs) {
|
||||
t.Errorf("Expected: %+v, received: %+v", expKeys.DestinationIDs, rcvKeys.DestinationIDs)
|
||||
}
|
||||
|
||||
@@ -144,6 +144,13 @@ func TestTpActionTriggers(t *testing.T) {
|
||||
} else if len(atrs) != 1 {
|
||||
t.Errorf("Calling v1.GetActionTriggers got: %v", atrs)
|
||||
}
|
||||
if atrs == nil {
|
||||
t.Errorf("Expecting atrs to not be nil")
|
||||
// atrs shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
if atrs[0].ID != "TestATR" ||
|
||||
atrs[0].UniqueID != "Unique atr id" ||
|
||||
*atrs[0].Balance.ID != "BID1" {
|
||||
@@ -157,6 +164,13 @@ func TestTpZeroCost(t *testing.T) {
|
||||
if err := tpRPC.Call("ApierV2.GetAccount", attrs, &acnt); err != nil {
|
||||
t.Error("Got error on ApierV2.GetAccount: ", err.Error())
|
||||
}
|
||||
if acnt == nil {
|
||||
t.Errorf("Expecting acnt to not be nil")
|
||||
// acnt shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
}
|
||||
balanceValueBefore := acnt.BalanceMap[utils.MONETARY][0].Value
|
||||
tStart := time.Date(2016, 3, 31, 0, 0, 0, 0, time.UTC)
|
||||
cd := engine.CallDescriptor{
|
||||
|
||||
Reference in New Issue
Block a user