mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Covered to 100% migratorcfg and radiuscfg
This commit is contained in:
committed by
Dan Christian Bogos
parent
0202e04587
commit
7bc822a643
@@ -43,7 +43,9 @@ func TestMigratorCgrCfgloadFromJsonCfg(t *testing.T) {
|
||||
utils.RedisClusterCfg: true,
|
||||
utils.ClusterSyncCfg: "10s",
|
||||
},
|
||||
Out_storDB_opts: map[string]interface{}{},
|
||||
Out_storDB_opts: map[string]interface{}{
|
||||
utils.RedisClusterCfg: true,
|
||||
},
|
||||
}
|
||||
expected := &MigratorCgrCfg{
|
||||
OutDataDBType: utils.REDIS,
|
||||
@@ -65,7 +67,9 @@ func TestMigratorCgrCfgloadFromJsonCfg(t *testing.T) {
|
||||
utils.ClusterSyncCfg: "10s",
|
||||
utils.ClusterOnDownDelayCfg: "0",
|
||||
},
|
||||
OutStorDBOpts: map[string]interface{}{},
|
||||
OutStorDBOpts: map[string]interface{}{
|
||||
utils.RedisClusterCfg: true,
|
||||
},
|
||||
}
|
||||
if cfgJson, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestRadiusAgentCfgloadFromJsonCfg(t *testing.T) {
|
||||
func TestRadiusAgentCfgloadFromJsonCfgCase1(t *testing.T) {
|
||||
cfgJSON := &RadiusAgentJsonCfg{
|
||||
Enabled: utils.BoolPointer(true),
|
||||
Listen_net: utils.StringPointer(utils.UDP),
|
||||
@@ -96,6 +96,56 @@ func TestRadiusAgentCfgloadFromJsonCfg(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRadiusAgentCfgloadFromJsonCfgCase2(t *testing.T) {
|
||||
cfgJSONStr := `{
|
||||
"radius_agent": {
|
||||
"request_processors": [
|
||||
{
|
||||
"id": "OutboundAUTHDryRun",
|
||||
},
|
||||
],
|
||||
},
|
||||
}`
|
||||
cfgJSON := &RadiusAgentJsonCfg{
|
||||
Request_processors: &[]*ReqProcessorJsnCfg{
|
||||
{
|
||||
ID: utils.StringPointer("OutboundAUTHDryRun"),
|
||||
},
|
||||
},
|
||||
}
|
||||
expected := &RadiusAgentCfg{
|
||||
RequestProcessors: []*RequestProcessor{
|
||||
{
|
||||
ID: "OutboundAUTHDryRun",
|
||||
},
|
||||
},
|
||||
}
|
||||
if jsonCfg, err := NewCGRConfigFromJsonStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
} else if err = jsonCfg.radiusAgentCfg.loadFromJsonCfg(cfgJSON, jsonCfg.generalCfg.RSRSep); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(jsonCfg.radiusAgentCfg.RequestProcessors[0].ID, expected.RequestProcessors[0].ID) {
|
||||
t.Errorf("Expected %+v, received %+v", utils.ToJSON(jsonCfg.radiusAgentCfg.RequestProcessors[0].ID),
|
||||
utils.ToJSON(expected.RequestProcessors[0].ID))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRadiusAgentCfgloadFromJsonCfgCase3(t *testing.T) {
|
||||
cfgJSON := &RadiusAgentJsonCfg{
|
||||
Request_processors: &[]*ReqProcessorJsnCfg{
|
||||
{
|
||||
Tenant: utils.StringPointer("a{*"),
|
||||
},
|
||||
},
|
||||
}
|
||||
expected := "invalid converter terminator in rule: <a{*>"
|
||||
if jsonCfg, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
} else if err = jsonCfg.radiusAgentCfg.loadFromJsonCfg(cfgJSON, jsonCfg.generalCfg.RSRSep); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expected %+v, received %+v", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRadiusAgentCfgAsMapInterface(t *testing.T) {
|
||||
cfgJSONStr := `{
|
||||
"radius_agent": {
|
||||
|
||||
Reference in New Issue
Block a user