Updated initSession and tests

This commit is contained in:
Trial97
2019-12-11 17:47:17 +02:00
parent 49489be7a2
commit 25e37dda2d
3 changed files with 9 additions and 7 deletions

View File

@@ -52,7 +52,6 @@ var (
testSSv1ItAuth,
testSSv1ItAuthWithDigest,
testSSv1ItInitiateSession,
testSSv1ItInitiateSessionWithDigest,
testSSv1ItUpdateSession,
testSSv1ItTerminateSession,
testSSv1ItProcessCDR,
@@ -61,6 +60,9 @@ var (
testSSv1ItForceUpdateSession,
testSSv1ItDynamicDebit,
testSSv1ItDeactivateSessions,
testSSv1ItInitiateSessionWithDigest, // no need for session terminate because is the last test
testSSv1ItStopCgrEngine,
}
)
@@ -388,7 +390,7 @@ func testSSv1ItInitiateSessionWithDigest(t *testing.T) {
Event: map[string]interface{}{
utils.Tenant: "cgrates.org",
utils.ToR: utils.VOICE,
utils.OriginID: "TestSSv1It1",
utils.OriginID: "TestSSv1It2",
utils.RequestType: sSV1RequestType,
utils.Account: "1001",
utils.Subject: "ANY2CNT",
@@ -525,7 +527,7 @@ func testSSv1ItTerminateSession(t *testing.T) {
aSessions := make([]*sessions.ExternalSession, 0)
if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
t.Errorf("Expected error %s received error %v and reply %s", utils.ErrNotFound, err, utils.ToJSON(aSessions))
}
}
@@ -719,7 +721,7 @@ func testSSv1ItForceUpdateSession(t *testing.T) {
}
var acnt *engine.Account
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
eAcntVal := 9.399500
eAcntVal := 9.55
if err := sSApierRpc.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil {
t.Error(err)
} else if acnt.BalanceMap[utils.MONETARY].GetTotalValue() != eAcntVal {
@@ -790,7 +792,7 @@ func testSSv1ItForceUpdateSession(t *testing.T) {
t.Errorf("wrong active ssesions: %s", utils.ToJSON(aSessions))
}
eAcntVal = 9.249500
eAcntVal = 9.4
if err := sSApierRpc.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil {
t.Error(err)
} else if acnt.BalanceMap[utils.MONETARY].GetTotalValue() != eAcntVal {

View File

@@ -355,7 +355,7 @@ func testRPCMethodsInitSession(t *testing.T) {
time.Sleep(1*time.Second + 500*time.Millisecond)
if err := rpcRpc.Call(utils.SessionSv1InitiateSession,
args, &rply); err == nil || err.Error() != "RALS_ERROR:ACCOUNT_DISABLED" {
args, &rply); err == nil || !(err.Error() == "RALS_ERROR:ACCOUNT_DISABLED" || err.Error() == utils.NewErrRALs(utils.ErrExists).Error()) { // ErrExist -> initSession twice
t.Error("Unexpected error returned", err)
}

View File

@@ -1398,7 +1398,7 @@ func (sS *SessionS) initSession(tnt string, evStart engine.MapEvent, clntConnID
DebitInterval: dbtItval,
ArgDispatcher: argDisp,
}
if sS.isIndexed(s, true) { // check if already exists
if sS.isIndexed(s, false) { // check if already exists
return nil, utils.ErrExists
}
if err = sS.forkSession(s); err != nil {