mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-16 05:39:54 +05:00
Renamed consts for chargers apis
This commit is contained in:
committed by
Dan Christian Bogos
parent
183bddb416
commit
fce4cfff3e
@@ -26,7 +26,7 @@ import (
|
||||
func init() {
|
||||
c := &CmdGetChargers{
|
||||
name: "chargers_profile",
|
||||
rpcMethod: utils.APIerSv1GetChargerProfile,
|
||||
rpcMethod: utils.AdminSv1GetChargerProfile,
|
||||
rpcParams: &utils.TenantID{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
func init() {
|
||||
c := &CmdGetChargerIDs{
|
||||
name: "chargers_profile_ids",
|
||||
rpcMethod: utils.APIerSv1GetChargerProfileIDs,
|
||||
rpcMethod: utils.AdminSv1GetChargerProfileIDs,
|
||||
rpcParams: &utils.PaginatorWithTenant{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
@@ -23,7 +23,7 @@ import "github.com/cgrates/cgrates/utils"
|
||||
func init() {
|
||||
c := &CmdRemoveChargers{
|
||||
name: "chargers_profile_remove",
|
||||
rpcMethod: utils.APIerSv1RemoveChargerProfile,
|
||||
rpcMethod: utils.AdminSv1RemoveChargerProfile,
|
||||
rpcParams: &utils.TenantIDWithAPIOpts{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
@@ -22,7 +22,7 @@ package console
|
||||
func init() {
|
||||
c := &CmdSetChargers{
|
||||
name: "chargers_profile_set",
|
||||
rpcMethod: utils.APIerSv1SetChargerProfile,
|
||||
rpcMethod: utils.AdminSv1SetChargerProfile,
|
||||
rpcParams: &v1.ChargerWithAPIOpts{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
@@ -1365,9 +1365,9 @@ func testITChargerProfileIndexes(t *testing.T) {
|
||||
FilterIDs: []string{"CHARGER_FLTR", "*string:~*req.Usage:~*req.Debited"},
|
||||
Weight: 10,
|
||||
}
|
||||
if err := dataManager.SetChargerProfile(chrgr1, true); err != nil {
|
||||
if err := dataManager.SetChargerProfile(context.Background(), chrgr1, true); err != nil {
|
||||
t.Error(err)
|
||||
} else if err := dataManager.SetChargerProfile(chrgr2, true); err != nil {
|
||||
} else if err := dataManager.SetChargerProfile(context.Background(), chrgr2, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1399,9 +1399,9 @@ func testITChargerProfileIndexes(t *testing.T) {
|
||||
}
|
||||
chrgr1.ID = "CHANGED_CHARGER_PRF1"
|
||||
chrgr2.ID = "CHANGED_CHARGER_PRF2"
|
||||
if err := dataManager.SetChargerProfile(chrgr1, true); err != nil {
|
||||
if err := dataManager.SetChargerProfile(context.Background(), chrgr1, true); err != nil {
|
||||
t.Error(err)
|
||||
} else if err := dataManager.SetChargerProfile(chrgr2, true); err != nil {
|
||||
} else if err := dataManager.SetChargerProfile(context.Background(), chrgr2, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ func testLoaderITWriteToDatabase(t *testing.T) {
|
||||
}
|
||||
|
||||
for tenatid, cpp := range loader.chargerProfiles {
|
||||
rcv, err := loader.dm.GetChargerProfile(tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
|
||||
rcv, err := loader.dm.GetChargerProfile(context.Background(), tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
|
||||
if err != nil {
|
||||
t.Errorf("Failed GetChargerProfile, tenant: %s, id: %s, error: %s ", cpp.Tenant, cpp.ID, err.Error())
|
||||
}
|
||||
|
||||
@@ -908,15 +908,15 @@ func testOnStorITChargerProfile(t *testing.T) {
|
||||
AttributeIDs: []string{"ATTR_1"},
|
||||
Weight: 20,
|
||||
}
|
||||
if _, rcvErr := onStor.GetChargerProfile("cgrates.org", "CPP_1",
|
||||
if _, rcvErr := onStor.GetChargerProfile(context.Background(), "cgrates.org", "CPP_1",
|
||||
true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
if err := onStor.SetChargerProfile(cpp, false); err != nil {
|
||||
if err := onStor.SetChargerProfile(context.Background(), cpp, false); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
//get from database
|
||||
if rcv, err := onStor.GetChargerProfile("cgrates.org", "CPP_1",
|
||||
if rcv, err := onStor.GetChargerProfile(context.Background(), "cgrates.org", "CPP_1",
|
||||
false, false, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !(reflect.DeepEqual(cpp, rcv)) {
|
||||
@@ -930,23 +930,23 @@ func testOnStorITChargerProfile(t *testing.T) {
|
||||
}
|
||||
//update
|
||||
cpp.FilterIDs = []string{"*string:~*req.Accout:1001", "*prefix:~*req.Destination:10"}
|
||||
if err := onStor.SetChargerProfile(cpp, false); err != nil {
|
||||
if err := onStor.SetChargerProfile(context.Background(), cpp, false); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
//get from database
|
||||
if rcv, err := onStor.GetChargerProfile("cgrates.org", "CPP_1",
|
||||
if rcv, err := onStor.GetChargerProfile(context.Background(), "cgrates.org", "CPP_1",
|
||||
false, false, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !(reflect.DeepEqual(cpp, rcv)) {
|
||||
t.Errorf("Expecting: %v, received: %v", cpp, rcv)
|
||||
}
|
||||
if err := onStor.RemoveChargerProfile(cpp.Tenant, cpp.ID,
|
||||
if err := onStor.RemoveChargerProfile(context.Background(), cpp.Tenant, cpp.ID,
|
||||
false); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
//check database if removed
|
||||
if _, rcvErr := onStor.GetChargerProfile("cgrates.org", "CPP_1",
|
||||
if _, rcvErr := onStor.GetChargerProfile(context.Background(), "cgrates.org", "CPP_1",
|
||||
false, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package migrator
|
||||
|
||||
import (
|
||||
"github.com/cgrates/birpc/context"
|
||||
"log"
|
||||
"path"
|
||||
"reflect"
|
||||
@@ -194,10 +195,10 @@ func testChrgITMigrateAndMove(t *testing.T) {
|
||||
switch chrgAction {
|
||||
case utils.Migrate: // for the momment only one version of chargers exists
|
||||
case utils.Move:
|
||||
if err := chrgMigrator.dmIN.DataManager().SetChargerProfile(chrgPrf, false); err != nil {
|
||||
if err := chrgMigrator.dmIN.DataManager().SetChargerProfile(context.Background(), chrgPrf, false); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := chrgMigrator.dmIN.DataManager().SetChargerProfile(chrgPrf2, false); err != nil {
|
||||
if err := chrgMigrator.dmIN.DataManager().SetChargerProfile(context.Background(), chrgPrf2, false); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
currentVersion := engine.CurrentDataDBVersions()
|
||||
@@ -206,7 +207,7 @@ func testChrgITMigrateAndMove(t *testing.T) {
|
||||
t.Error("Error when setting version for Chargers ", err.Error())
|
||||
}
|
||||
|
||||
_, err = chrgMigrator.dmOut.DataManager().GetChargerProfile("cgrates.org",
|
||||
_, err = chrgMigrator.dmOut.DataManager().GetChargerProfile(context.Background(), "cgrates.org",
|
||||
"CHRG_1", false, false, utils.NonTransactional)
|
||||
if err != utils.ErrNotFound {
|
||||
t.Error(err)
|
||||
@@ -216,23 +217,23 @@ func testChrgITMigrateAndMove(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error("Error when migrating Chargers ", err.Error())
|
||||
}
|
||||
if result, err := chrgMigrator.dmOut.DataManager().GetChargerProfile("cgrates.org",
|
||||
if result, err := chrgMigrator.dmOut.DataManager().GetChargerProfile(context.Background(), "cgrates.org",
|
||||
"CHRG_1", false, false, utils.NonTransactional); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, chrgPrf) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", chrgPrf, result)
|
||||
}
|
||||
if result, err := chrgMigrator.dmOut.DataManager().GetChargerProfile("cgrates.com",
|
||||
if result, err := chrgMigrator.dmOut.DataManager().GetChargerProfile(context.Background(), "cgrates.com",
|
||||
"CHRG_1", false, false, utils.NonTransactional); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, chrgPrf2) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", chrgPrf2, result)
|
||||
}
|
||||
if _, err = chrgMigrator.dmIN.DataManager().GetChargerProfile("cgrates.org",
|
||||
if _, err = chrgMigrator.dmIN.DataManager().GetChargerProfile(context.Background(), "cgrates.org",
|
||||
"CHRG_1", false, false, utils.NonTransactional); err == nil || err != utils.ErrNotFound {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = chrgMigrator.dmIN.DataManager().GetChargerProfile("cgrates.com",
|
||||
if _, err = chrgMigrator.dmIN.DataManager().GetChargerProfile(context.Background(), "cgrates.com",
|
||||
"CHRG_1", false, false, utils.NonTransactional); err == nil || err != utils.ErrNotFound {
|
||||
t.Error(err)
|
||||
} else if chrgMigrator.stats[utils.Chargers] != 2 {
|
||||
|
||||
@@ -1322,10 +1322,10 @@ const (
|
||||
ChargerSv1Ping = "ChargerSv1.Ping"
|
||||
ChargerSv1GetChargersForEvent = "ChargerSv1.GetChargersForEvent"
|
||||
ChargerSv1ProcessEvent = "ChargerSv1.ProcessEvent"
|
||||
APIerSv1GetChargerProfile = "APIerSv1.GetChargerProfile"
|
||||
APIerSv1RemoveChargerProfile = "APIerSv1.RemoveChargerProfile"
|
||||
APIerSv1SetChargerProfile = "APIerSv1.SetChargerProfile"
|
||||
APIerSv1GetChargerProfileIDs = "APIerSv1.GetChargerProfileIDs"
|
||||
AdminSv1GetChargerProfile = "AdminSv1.GetChargerProfile"
|
||||
AdminSv1RemoveChargerProfile = "AdminSv1.RemoveChargerProfile"
|
||||
AdminSv1SetChargerProfile = "AdminSv1.SetChargerProfile"
|
||||
AdminSv1GetChargerProfileIDs = "AdminSv1.GetChargerProfileIDs"
|
||||
)
|
||||
|
||||
// ThresholdS APIs
|
||||
|
||||
Reference in New Issue
Block a user