mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fix tests after adding opts for stats
This commit is contained in:
committed by
Dan Christian Bogos
parent
c861adc043
commit
ef8f891548
@@ -1119,6 +1119,10 @@ func TestDfStatServiceJsonCfg(t *testing.T) {
|
||||
Prefix_indexed_fields: &[]string{},
|
||||
Suffix_indexed_fields: &[]string{},
|
||||
Nested_fields: utils.BoolPointer(false),
|
||||
Opts: &StatsOptsJson{
|
||||
ProfileIDs: &[]string{},
|
||||
ProfileIgnoreFilters: utils.BoolPointer(false),
|
||||
},
|
||||
}
|
||||
dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON))
|
||||
if err != nil {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -46,6 +46,9 @@ func TestStatSCfgloadFromJsonCfgCase1(t *testing.T) {
|
||||
PrefixIndexedFields: &[]string{"*req.index1", "*req.index2"},
|
||||
SuffixIndexedFields: &[]string{"*req.index1", "*req.index2"},
|
||||
NestedFields: true,
|
||||
Opts: &StatsOpts{
|
||||
ProfileIDs: []string{},
|
||||
},
|
||||
}
|
||||
jsonCfg := NewDefaultCGRConfig()
|
||||
if err = jsonCfg.statsCfg.loadFromJSONCfg(cfgJSON); err != nil {
|
||||
@@ -79,6 +82,10 @@ func TestStatSCfgAsMapInterface(t *testing.T) {
|
||||
utils.PrefixIndexedFieldsCfg: []string{},
|
||||
utils.SuffixIndexedFieldsCfg: []string{},
|
||||
utils.NestedFieldsCfg: false,
|
||||
utils.OptsCfg: map[string]interface{}{
|
||||
utils.MetaProfileIDs: []string{},
|
||||
utils.MetaProfileIgnoreFiltersCfg: false,
|
||||
},
|
||||
}
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
@@ -111,11 +118,15 @@ func TestStatSCfgAsMapInterface1(t *testing.T) {
|
||||
utils.PrefixIndexedFieldsCfg: []string{"*req.prefix_indexed_fields1", "*req.prefix_indexed_fields2"},
|
||||
utils.SuffixIndexedFieldsCfg: []string{"*req.suffix_indexed_fields"},
|
||||
utils.NestedFieldsCfg: true,
|
||||
utils.OptsCfg: map[string]interface{}{
|
||||
utils.MetaProfileIDs: []string{},
|
||||
utils.MetaProfileIgnoreFiltersCfg: false,
|
||||
},
|
||||
}
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
} else if rcv := cgrCfg.statsCfg.AsMapInterface(); !reflect.DeepEqual(rcv, eMap) {
|
||||
t.Errorf("Expected %+v \n, received %+v", eMap, rcv)
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
func TestStatSCfgClone(t *testing.T) {
|
||||
@@ -129,6 +140,9 @@ func TestStatSCfgClone(t *testing.T) {
|
||||
PrefixIndexedFields: &[]string{"*req.index1", "*req.index2"},
|
||||
SuffixIndexedFields: &[]string{"*req.index1", "*req.index2"},
|
||||
NestedFields: true,
|
||||
Opts: &StatsOpts{
|
||||
ProfileIDs: []string{},
|
||||
},
|
||||
}
|
||||
rcv := ban.Clone()
|
||||
if !reflect.DeepEqual(ban, rcv) {
|
||||
|
||||
@@ -335,7 +335,7 @@ func (sS *StatService) processEvent(tnt string, args *utils.CGREvent) (statQueue
|
||||
}
|
||||
}
|
||||
ignFilters := sS.cgrcfg.StatSCfg().Opts.ProfileIgnoreFilters
|
||||
if opt, has := args.APIOpts[utils.OptsStatsProfileIDs]; has {
|
||||
if opt, has := args.APIOpts[utils.OptsStatsProfileIgnoreFilters]; has {
|
||||
if ignFilters, err = utils.IfaceAsBool(opt); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -408,7 +408,7 @@ func (sS *StatService) V1GetStatQueuesForEvent(args *utils.CGREvent, reply *[]st
|
||||
}
|
||||
}
|
||||
ignFilters := sS.cgrcfg.StatSCfg().Opts.ProfileIgnoreFilters
|
||||
if opt, has := args.APIOpts[utils.OptsStatsProfileIDs]; has {
|
||||
if opt, has := args.APIOpts[utils.OptsStatsProfileIgnoreFilters]; has {
|
||||
if ignFilters, err = utils.IfaceAsBool(opt); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ var (
|
||||
utils.Usage: 135 * time.Second,
|
||||
utils.Cost: 123.0,
|
||||
},
|
||||
APIOpts: map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
@@ -126,6 +127,7 @@ var (
|
||||
"Weight": "15.0",
|
||||
utils.Usage: 45 * time.Second,
|
||||
},
|
||||
APIOpts: map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
@@ -134,6 +136,7 @@ var (
|
||||
"Stats": "StatQueueProfilePrefix",
|
||||
utils.Usage: 30 * time.Second,
|
||||
},
|
||||
APIOpts: map[string]interface{}{},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user