Updated routes tests

This commit is contained in:
Trial97
2021-05-27 09:19:54 +03:00
committed by Dan Christian Bogos
parent ed81fe3261
commit 453e005cfa
4 changed files with 21 additions and 20 deletions

View File

@@ -1837,10 +1837,10 @@ func testITTestIndexingWithEmptyFltrID2(t *testing.T) {
Weight: 20,
}
if err := dataManager.SetRouteProfile(splProfile, true); err != nil {
if err := dataManager.SetRouteProfile(context.TODO(), splProfile, true); err != nil {
t.Error(err)
}
if err := dataManager.SetRouteProfile(splProfile2, true); err != nil {
if err := dataManager.SetRouteProfile(context.TODO(), splProfile2, true); err != nil {
t.Error(err)
}
eIdxes := map[string]utils.StringSet{
@@ -1893,10 +1893,10 @@ func testITTestIndexingWithEmptyFltrID2(t *testing.T) {
splProfile.FilterIDs = []string{"FIRST", "*prefix:~*req.Account:123"}
splProfile2.ID = "SPL_WITH_FILTER2"
splProfile2.FilterIDs = []string{"FIRST"}
if err := dataManager.SetRouteProfile(splProfile, true); err != nil {
if err := dataManager.SetRouteProfile(context.TODO(), splProfile, true); err != nil {
t.Error(err)
}
if err := dataManager.SetRouteProfile(splProfile2, true); err != nil {
if err := dataManager.SetRouteProfile(context.TODO(), splProfile2, true); err != nil {
t.Error(err)
}
expIdx := map[string]utils.StringSet{

View File

@@ -290,7 +290,7 @@ func testLoaderITWriteToDatabase(t *testing.T) {
}
for tenatid, th := range loader.routeProfiles {
rcv, err := loader.dm.GetRouteProfile(tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
rcv, err := loader.dm.GetRouteProfile(context.TODO(), tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
if err != nil {
t.Errorf("Failed GetRouteProfile, tenant: %s, id: %s, error: %s ", th.Tenant, th.ID, err.Error())
}

View File

@@ -679,22 +679,22 @@ func testOnStorITRouteProfile(t *testing.T) {
},
Weight: 20,
}
if _, rcvErr := onStor.GetRouteProfile("cgrates.org", "SPRF_1",
if _, rcvErr := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1",
true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
t.Error(rcvErr)
}
if err := onStor.SetRouteProfile(splProfile, false); err != nil {
if err := onStor.SetRouteProfile(context.TODO(), splProfile, false); err != nil {
t.Error(err)
}
//get from cache
if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1",
if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1",
true, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !(reflect.DeepEqual(splProfile, rcv)) {
t.Errorf("Expecting: %v, received: %v", splProfile, rcv)
}
//get from database
if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1",
if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1",
false, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !(reflect.DeepEqual(splProfile, rcv)) {
@@ -729,35 +729,35 @@ func testOnStorITRouteProfile(t *testing.T) {
RouteParameters: "param2",
},
}
if err := onStor.SetRouteProfile(splProfile, false); err != nil {
if err := onStor.SetRouteProfile(context.TODO(), splProfile, false); err != nil {
t.Error(err)
}
//get from cache
if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1",
if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1",
true, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !(reflect.DeepEqual(splProfile, rcv)) {
t.Errorf("Expecting: %v, received: %v", splProfile, rcv)
}
//get from database
if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1",
if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1",
false, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !(reflect.DeepEqual(splProfile, rcv)) {
t.Errorf("Expecting: %v, received: %v", splProfile, rcv)
}
if err := onStor.RemoveRouteProfile(splProfile.Tenant, splProfile.ID,
if err := onStor.RemoveRouteProfile(context.TODO(), splProfile.Tenant, splProfile.ID,
false); err != nil {
t.Error(err)
}
//check cache if removed
if _, rcvErr := onStor.GetRouteProfile("cgrates.org", "SPRF_1",
if _, rcvErr := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1",
true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
t.Error(rcvErr)
}
//check database if removed
if _, rcvErr := onStor.GetRouteProfile("cgrates.org", "SPRF_1",
if _, rcvErr := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1",
false, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
t.Error(rcvErr)
}

View File

@@ -26,6 +26,7 @@ import (
"reflect"
"testing"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -196,10 +197,10 @@ func testSupITMigrateAndMove(t *testing.T) {
switch supAction {
case utils.Migrate: // for the momment only one version of rating plans exists
case utils.Move:
if err := supMigrator.dmIN.DataManager().SetRouteProfile(supPrfl, true); err != nil {
if err := supMigrator.dmIN.DataManager().SetRouteProfile(context.TODO(), supPrfl, true); err != nil {
t.Error(err)
}
if _, err := supMigrator.dmIN.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional); err != nil {
if _, err := supMigrator.dmIN.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional); err != nil {
t.Error(err)
}
currentVersion := engine.CurrentDataDBVersions()
@@ -208,7 +209,7 @@ func testSupITMigrateAndMove(t *testing.T) {
t.Error("Error when setting version for Suppliers ", err.Error())
}
_, err = supMigrator.dmOut.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional)
_, err = supMigrator.dmOut.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional)
if err != utils.ErrNotFound {
t.Error(err)
}
@@ -217,14 +218,14 @@ func testSupITMigrateAndMove(t *testing.T) {
if err != nil {
t.Error("Error when migrating Suppliers ", err.Error())
}
result, err := supMigrator.dmOut.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional)
result, err := supMigrator.dmOut.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(result, supPrfl) {
t.Errorf("Expecting: %+v, received: %+v", supPrfl, result)
}
result, err = supMigrator.dmIN.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional)
result, err = supMigrator.dmIN.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional)
if err != utils.ErrNotFound {
t.Error(err)
} else if supMigrator.stats[utils.Routes] != 1 {