mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 08:38:45 +05:00
Added verification for tests in case of internal db
This commit is contained in:
committed by
Dan Christian Bogos
parent
2ab2e60f0a
commit
c21a60513c
@@ -23,6 +23,8 @@ package apis
|
||||
|
||||
import (
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/birpc"
|
||||
@@ -56,12 +58,11 @@ func TestIdxCheckAfterLoad(t *testing.T) {
|
||||
case utils.MetaInternal:
|
||||
idxLoadConfigDIR = "session_volume_discount_internal"
|
||||
case utils.MetaMySQL:
|
||||
t.Skip()
|
||||
idxLoadConfigDIR = "session_volume_discount_mysql"
|
||||
case utils.MetaMongo:
|
||||
t.Skip()
|
||||
idxLoadConfigDIR = "session_volume_discount_mongo"
|
||||
case utils.MetaPostgres:
|
||||
t.Skip()
|
||||
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
@@ -120,29 +121,61 @@ func testIdxLoadTariffPlan(t *testing.T) {
|
||||
}
|
||||
|
||||
func testIdxLoadCheckIndexes(t *testing.T) {
|
||||
expected := []string{
|
||||
"*none:*any:*any:RP_ABS_BALANCE1",
|
||||
"*none:*any:*any:RP_ABS_BALANCE2",
|
||||
"*none:*any:*any:RP_CNCRT_BALANCE1",
|
||||
"*none:*any:*any:RP_ROUTE2",
|
||||
}
|
||||
//get indexes *rate_profiles
|
||||
var reply []string
|
||||
if err := idxLoadBiRPC.Call(context.Background(), utils.AdminSv1GetFilterIndexes,
|
||||
&AttrGetFilterIndexes{
|
||||
ItemType: utils.MetaRateProfiles,
|
||||
}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
}, &reply); (err == nil || err.Error() != utils.ErrNotFound.Error()) && idxLoadConfigDIR == "session_volume_discount_internal" {
|
||||
t.Error(err)
|
||||
} else {
|
||||
sort.Strings(expected)
|
||||
sort.Strings(reply)
|
||||
if !reflect.DeepEqual(expected, reply) && idxLoadConfigDIR != "session_volume_discount_internal" {
|
||||
t.Errorf("Expected %+v, received %+v", expected, reply)
|
||||
}
|
||||
}
|
||||
|
||||
expected = []string{
|
||||
"*none:*any:*any:CHRG_SUPPLIER",
|
||||
"*none:*any:*any:CHRG_CUSTOMER",
|
||||
}
|
||||
//get indexes *chargers
|
||||
if err := idxLoadBiRPC.Call(context.Background(), utils.AdminSv1GetFilterIndexes,
|
||||
&AttrGetFilterIndexes{
|
||||
ItemType: utils.MetaChargers,
|
||||
}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
}, &reply); (err == nil || err.Error() != utils.ErrNotFound.Error()) && idxLoadConfigDIR == "session_volume_discount_internal" {
|
||||
t.Error(err)
|
||||
} else {
|
||||
sort.Strings(expected)
|
||||
sort.Strings(reply)
|
||||
if !reflect.DeepEqual(expected, reply) && idxLoadConfigDIR != "session_volume_discount_internal" {
|
||||
t.Errorf("Expected %+v, received %+v", expected, reply)
|
||||
}
|
||||
}
|
||||
|
||||
expected = []string{
|
||||
"*none:*any:*any:ATTR_RATES",
|
||||
"*string:*req.Account:ACCOUNT1:ATTR_ACCOUNTS",
|
||||
}
|
||||
//get indexes *attributes
|
||||
if err := idxLoadBiRPC.Call(context.Background(), utils.AdminSv1GetFilterIndexes,
|
||||
&AttrGetFilterIndexes{
|
||||
ItemType: utils.MetaAttributes,
|
||||
}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
}, &reply); (err == nil || err.Error() != utils.ErrNotFound.Error()) && idxLoadConfigDIR == "session_volume_discount_internal" {
|
||||
t.Error(err)
|
||||
} else {
|
||||
sort.Strings(expected)
|
||||
sort.Strings(reply)
|
||||
if !reflect.DeepEqual(expected, reply) && idxLoadConfigDIR != "session_volume_discount_internal" {
|
||||
t.Errorf("Expected %+v, received %+v", expected, reply)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,11 +132,15 @@ func testSessVolDiscApierRpcConn(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSessVolDiscLoadersLoad(t *testing.T) {
|
||||
caching := utils.MetaReload
|
||||
if tSessVolDiscCfgDIR == "session_volume_discount_internal" {
|
||||
caching = utils.MetaNone
|
||||
}
|
||||
var reply string
|
||||
if err := tSessVolDiscBiRPC.Call(context.Background(), utils.LoaderSv1Load,
|
||||
&loaders.ArgsProcessFolder{
|
||||
// StopOnError: true,
|
||||
Caching: utils.StringPointer(utils.MetaNone),
|
||||
Caching: utils.StringPointer(caching),
|
||||
}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
|
||||
Reference in New Issue
Block a user