mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fixed the error description and added testsm in config
This commit is contained in:
committed by
Dan Christian Bogos
parent
d7fd8fc62b
commit
26fc655f2c
@@ -931,7 +931,7 @@ func TestRadiusAgentCfg(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDbDefaults(t *testing.T) {
|
||||
func TestDbDefaultsMetaDynamic(t *testing.T) {
|
||||
dbdf := newDbDefaults()
|
||||
flagInput := utils.MetaDynamic
|
||||
dbs := []string{utils.MONGO, utils.REDIS, utils.MYSQL, utils.INTERNAL}
|
||||
@@ -959,6 +959,34 @@ func TestDbDefaults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDbDefaults(t *testing.T) {
|
||||
dbdf := newDbDefaults()
|
||||
flagInput := "NonMetaDynamic"
|
||||
dbs := []string{utils.MONGO, utils.REDIS, utils.MYSQL, utils.INTERNAL, utils.POSTGRES}
|
||||
for _, dbtype := range dbs {
|
||||
host := dbdf.dbHost(dbtype, flagInput)
|
||||
if host != flagInput {
|
||||
t.Errorf("Expected %+v, received %+v", flagInput, host)
|
||||
}
|
||||
user := dbdf.dbUser(dbtype, flagInput)
|
||||
if user != flagInput {
|
||||
t.Errorf("Expected %+v, received %+v", flagInput, user)
|
||||
}
|
||||
port := dbdf.dbPort(dbtype, "1234")
|
||||
if port != "1234" {
|
||||
t.Errorf("Expected %+v, received %+v", "1234", port)
|
||||
}
|
||||
name := dbdf.dbName(dbtype, utils.CGRATES)
|
||||
if name != utils.CGRATES {
|
||||
t.Errorf("Expected %+v, received %+v", utils.CGRATES, name)
|
||||
}
|
||||
pass := dbdf.dbPass(dbtype, utils.EmptyString)
|
||||
if pass != utils.EmptyString {
|
||||
t.Errorf("Expected %+v, received %+v", utils.EmptyString, pass)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCgrLoaderCfgITDefaults(t *testing.T) {
|
||||
eCfg := LoaderSCfgs{
|
||||
{
|
||||
|
||||
@@ -210,7 +210,7 @@ func TestDNSAgentCfgAsMapInterface(t *testing.T) {
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
} else if rcv := cgrCfg.dnsAgentCfg.AsMapInterface(utils.EmptyString); !reflect.DeepEqual(eMap, rcv) {
|
||||
t.Errorf("Expecetd %+v, received %+v", eMap, rcv)
|
||||
t.Errorf("Expected %+v, received %+v", eMap, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,6 +273,6 @@ func TestDNSAgentCfgAsMapInterface1(t *testing.T) {
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
} else if rcv := cgrCfg.dnsAgentCfg.AsMapInterface(cgrCfg.generalCfg.RSRSep); !reflect.DeepEqual(eMap, rcv) {
|
||||
t.Errorf("Expecetd %+v \n, received %+v", utils.ToIJSON(eMap), utils.ToIJSON(rcv))
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToIJSON(eMap), utils.ToIJSON(rcv))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,18 +314,20 @@ func (eeC *EventExporterCfg) AsMapInterface(separator string) (initialMP map[str
|
||||
initialMP = map[string]interface{}{
|
||||
utils.IDCfg: eeC.ID,
|
||||
utils.TypeCfg: eeC.Type,
|
||||
utils.ExportPath: eeC.ExportPath,
|
||||
utils.ExportPathCfg: eeC.FieldSep,
|
||||
utils.ExportPathCfg: eeC.ExportPath,
|
||||
utils.FieldSepCfg: eeC.FieldSep,
|
||||
utils.TimezoneCfg: eeC.Timezone,
|
||||
utils.FiltersCfg: eeC.Filters,
|
||||
utils.FlagsCfg: eeC.Flags.SliceFlags(),
|
||||
utils.FlagsCfg: []string{},
|
||||
utils.AttributeContextCfg: eeC.AttributeSCtx,
|
||||
utils.AttributeIDsCfg: eeC.AttributeSIDs,
|
||||
utils.SynchronousCfg: eeC.Synchronous,
|
||||
utils.AttemptsCfg: eeC.Attempts,
|
||||
utils.FieldSeparatorCfg: eeC.FieldSep,
|
||||
utils.OptsCfg: eeC.Opts,
|
||||
}
|
||||
if flags := eeC.Flags.SliceFlags(); len(flags) != 0 {
|
||||
initialMP[utils.FlagsCfg] = flags
|
||||
}
|
||||
if eeC.Tenant != nil {
|
||||
var tenant string
|
||||
values := make([]string, len(eeC.Tenant))
|
||||
|
||||
@@ -682,12 +682,12 @@ func TestEEsCfgAsMapInterface(t *testing.T) {
|
||||
utils.TypeCfg: "*file_csv",
|
||||
utils.ExportPathCfg: "/tmp/testCSV",
|
||||
utils.OptsCfg: map[string]interface{}{},
|
||||
utils.TenantCfg: NewRSRParsersMustCompile("~*req.Destination1", utils.INFIELD_SEP),
|
||||
utils.TenantCfg: "~*req.Destination1",
|
||||
utils.TimezoneCfg: "UTC",
|
||||
utils.FiltersCfg: []string{},
|
||||
utils.FlagsCfg: utils.FlagsWithParams{},
|
||||
utils.FlagsCfg: []string{},
|
||||
utils.AttributeIDsCfg: []string{},
|
||||
utils.AttributeContextCfg: nil,
|
||||
utils.AttributeContextCfg: utils.EmptyString,
|
||||
utils.SynchronousCfg: false,
|
||||
utils.AttemptsCfg: 1,
|
||||
utils.FieldSepCfg: ",",
|
||||
@@ -707,19 +707,23 @@ func TestEEsCfgAsMapInterface(t *testing.T) {
|
||||
} else {
|
||||
rcv := cgrCfg.eesCfg.AsMapInterface(cgrCfg.generalCfg.RSRSep)
|
||||
if len(rcv[utils.ExportersCfg].([]map[string]interface{})) != 2 {
|
||||
t.Errorf("Expecetd %+v, received %+v", 2, len(rcv[utils.ExportersCfg].([]map[string]interface{})))
|
||||
} else if !reflect.DeepEqual(eMap[utils.ExportersCfg].([]map[string]interface{})[0][utils.Flags],
|
||||
rcv[utils.ExportersCfg].([]map[string]interface{})[1][utils.Flags]) {
|
||||
t.Errorf("Expecetd %+v, received %+v", eMap[utils.ExportersCfg].([]map[string]interface{})[0][utils.Flags],
|
||||
rcv[utils.ExportersCfg].([]map[string]interface{})[1][utils.Flags])
|
||||
t.Errorf("Expected %+v, received %+v", 2, len(rcv[utils.ExportersCfg].([]map[string]interface{})))
|
||||
} else if !reflect.DeepEqual(eMap[utils.ExportersCfg].([]map[string]interface{})[0][utils.FieldsCfg].([]map[string]interface{})[0][utils.ValueCfg],
|
||||
rcv[utils.ExportersCfg].([]map[string]interface{})[1][utils.FieldsCfg].([]map[string]interface{})[0][utils.ValueCfg]) {
|
||||
t.Errorf("Expected %+v, received %+v", eMap[utils.ExportersCfg].([]map[string]interface{})[0][utils.FieldsCfg].([]map[string]interface{})[0][utils.ValueCfg],
|
||||
rcv[utils.ExportersCfg].([]map[string]interface{})[1][utils.FieldsCfg].([]map[string]interface{})[0][utils.ValueCfg])
|
||||
} else if !reflect.DeepEqual(eMap[utils.AttributeSConnsCfg], rcv[utils.AttributeSConnsCfg]) {
|
||||
t.Errorf("Expected %+v, received %+v", eMap[utils.AttributeSConnsCfg], rcv[utils.AttributeSConnsCfg])
|
||||
} else if !reflect.DeepEqual(eMap[utils.CacheCfg].(map[string]interface{})[utils.MetaFileCSV], rcv[utils.CacheCfg].(map[string]interface{})[utils.MetaFileCSV]) {
|
||||
t.Errorf("Expected %+v \n, received %+v", eMap[utils.CacheCfg].(map[string]interface{})[utils.MetaFileCSV], rcv[utils.CacheCfg].(map[string]interface{})[utils.MetaFileCSV])
|
||||
}
|
||||
rcv[utils.ExportersCfg].([]map[string]interface{})[1][utils.FieldsCfg] = nil
|
||||
eMap[utils.ExportersCfg].([]map[string]interface{})[0][utils.FieldsCfg] = nil
|
||||
if !reflect.DeepEqual(rcv[utils.ExportersCfg].([]map[string]interface{})[1],
|
||||
eMap[utils.ExportersCfg].([]map[string]interface{})[0]) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(rcv[utils.ExportersCfg].([]map[string]interface{})[1]),
|
||||
utils.ToJSON(eMap[utils.ExportersCfg].([]map[string]interface{})[0]))
|
||||
}
|
||||
rcv[utils.ExportersCfg] = nil
|
||||
eMap[utils.ExportersCfg] = nil
|
||||
if !reflect.DeepEqual(rcv, eMap) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1146,7 +1146,7 @@ func TestERsloadFromJsonCfg(t *testing.T) {
|
||||
func TestGetDefaultExporter(t *testing.T) {
|
||||
ees := new(EEsCfg)
|
||||
if dft := ees.GetDefaultExporter(); dft != nil {
|
||||
t.Fatalf("Expeceted no default cfg, received: %s", utils.ToJSON(dft))
|
||||
t.Fatalf("Expected no default cfg, received: %s", utils.ToJSON(dft))
|
||||
}
|
||||
if cfgCgr, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -200,7 +200,7 @@ func TestRadiusAgentCfgAsMapInterface(t *testing.T) {
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
} else if rcv := cgrCfg.radiusAgentCfg.AsMapInterface(cgrCfg.generalCfg.RSRSep); !reflect.DeepEqual(rcv, eMap) {
|
||||
t.Errorf("Expecetd %+v \n, received %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +225,6 @@ func TestRadiusAgentCfgAsMapInterface1(t *testing.T) {
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
} else if rcv := cgrCfg.radiusAgentCfg.AsMapInterface(cgrCfg.generalCfg.RSRSep); !reflect.DeepEqual(rcv, eMap) {
|
||||
t.Errorf("Expecetd %+v \n, received %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func TestSureTaxCfgloadFromJsonCfgCase1(t *testing.T) {
|
||||
} else if err = jsonCfg.sureTaxCfg.loadFromJsonCfg(cfgJSON); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expected, jsonCfg.sureTaxCfg) {
|
||||
t.Errorf("Expecetd %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(jsonCfg.sureTaxCfg))
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(jsonCfg.sureTaxCfg))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ func testDsphGetNodeID() (id string, err error) {
|
||||
|
||||
func testDsphBeforeDsphStart(t *testing.T) {
|
||||
if _, err := testDsphGetNodeID(); err == nil || err.Error() != utils.ErrHostNotFound.Error() {
|
||||
t.Errorf("Expeceted error: %s received: %v", utils.ErrHostNotFound, err)
|
||||
t.Errorf("Expected error: %s received: %v", utils.ErrHostNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ func testDsphStopEngines(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := testDsphGetNodeID(); err == nil || err.Error() != utils.ErrHostNotFound.Error() {
|
||||
t.Errorf("Expeceted error: %s received: %v", utils.ErrHostNotFound, err)
|
||||
t.Errorf("Expected error: %s received: %v", utils.ErrHostNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,14 +169,14 @@ func testSes2ItAsActiveSessions(t *testing.T) {
|
||||
}, &count); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if count != 2 { // 2 chargers
|
||||
t.Errorf("Expeced 2 session received %v session(s)", count)
|
||||
t.Errorf("Expected 2 session received %v session(s)", count)
|
||||
}
|
||||
if err := ses2RPC.Call(utils.SessionSv1GetActiveSessionsCount, utils.SessionFilter{
|
||||
Filters: []string{"*string:~*req.Account:1002"},
|
||||
}, &count); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if count != 0 {
|
||||
t.Errorf("Expeced 0 session received %v session(s)", count)
|
||||
t.Errorf("Expected 0 session received %v session(s)", count)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ func TestNewErrChargerS(t *testing.T) {
|
||||
func TestNewErrStatS(t *testing.T) {
|
||||
expected := "STATS_ERROR:NOT_FOUND"
|
||||
if rcv := NewErrStatS(ErrNotFound); rcv.Error() != expected {
|
||||
t.Errorf("Expecetd %+q, receiveed %+q", expected, rcv.Error())
|
||||
t.Errorf("Expected %+q, receiveed %+q", expected, rcv.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -257,37 +257,37 @@ func TestStringToInterface(t *testing.T) {
|
||||
func TestIfaceAsString(t *testing.T) {
|
||||
val := interface{}("string1")
|
||||
if rply := IfaceAsString(val); rply != "string1" {
|
||||
t.Errorf("Expeced string1 ,recived %+v", rply)
|
||||
t.Errorf("Expected string1 ,recived %+v", rply)
|
||||
}
|
||||
val = interface{}(123)
|
||||
if rply := IfaceAsString(val); rply != "123" {
|
||||
t.Errorf("Expeced 123 ,recived %+v", rply)
|
||||
t.Errorf("Expected 123 ,recived %+v", rply)
|
||||
}
|
||||
val = interface{}([]byte("byte_val"))
|
||||
if rply := IfaceAsString(val); rply != "byte_val" {
|
||||
t.Errorf("Expeced byte_val ,recived %+v", rply)
|
||||
t.Errorf("Expected byte_val ,recived %+v", rply)
|
||||
}
|
||||
val = interface{}(true)
|
||||
if rply := IfaceAsString(val); rply != "true" {
|
||||
t.Errorf("Expeced true ,recived %+v", rply)
|
||||
t.Errorf("Expected true ,recived %+v", rply)
|
||||
}
|
||||
if rply := IfaceAsString(time.Duration(1 * time.Second)); rply != "1s" {
|
||||
t.Errorf("Expeced 1s ,recived %+v", rply)
|
||||
t.Errorf("Expected 1s ,recived %+v", rply)
|
||||
}
|
||||
if rply := IfaceAsString(nil); rply != "" {
|
||||
t.Errorf("Expeced ,recived %+v", rply)
|
||||
t.Errorf("Expected ,recived %+v", rply)
|
||||
}
|
||||
val = interface{}(net.ParseIP("127.0.0.1"))
|
||||
if rply := IfaceAsString(val); rply != "127.0.0.1" {
|
||||
t.Errorf("Expeced ,recived %+v", rply)
|
||||
t.Errorf("Expected ,recived %+v", rply)
|
||||
}
|
||||
val = interface{}(10.23)
|
||||
if rply := IfaceAsString(val); rply != "10.23" {
|
||||
t.Errorf("Expeced ,recived %+v", rply)
|
||||
t.Errorf("Expected ,recived %+v", rply)
|
||||
}
|
||||
val = interface{}(time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC))
|
||||
if rply := IfaceAsString(val); rply != "2009-11-10T23:00:00Z" {
|
||||
t.Errorf("Expeced ,recived %+v", rply)
|
||||
t.Errorf("Expected ,recived %+v", rply)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user