mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Covered stordbcfg to almost 100%
This commit is contained in:
committed by
Dan Christian Bogos
parent
aa0ad1513f
commit
8b54e1f48b
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestStoreDbCfgloadFromJsonCfg(t *testing.T) {
|
||||
func TestStoreDbCfgloadFromJsonCfgCase1(t *testing.T) {
|
||||
cfgJSON := &DbJsonCfg{
|
||||
Db_type: utils.StringPointer(utils.MYSQL),
|
||||
Db_host: utils.StringPointer("127.0.0.1"),
|
||||
@@ -97,6 +97,41 @@ func TestStoreDbCfgloadFromJsonCfg(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreDbCfgloadFromJsonCfgCase2(t *testing.T) {
|
||||
storDbJson := &DbJsonCfg{
|
||||
Replication_conns: &[]string{utils.MetaInternal},
|
||||
}
|
||||
expected := "Replication connection ID needs to be different than *internal"
|
||||
if jsonCfg, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
} else if err = jsonCfg.storDbCfg.loadFromJsonCfg(storDbJson); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expected %+v, received %+v", storDbJson, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreDbCfgloadFromJsonCfgCase3(t *testing.T) {
|
||||
storDbJson := &DbJsonCfg{
|
||||
Remote_conns: &[]string{utils.MetaInternal},
|
||||
}
|
||||
expected := "Remote connection ID needs to be different than *internal"
|
||||
if jsonCfg, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
} else if err = jsonCfg.storDbCfg.loadFromJsonCfg(storDbJson); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expected %+v, received %+v", storDbJson, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreDbCfgloadFromJsonCfgCase4(t *testing.T) {
|
||||
if jsonCfg, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
clonedStoreDb := jsonCfg.storDbCfg.Clone()
|
||||
if !reflect.DeepEqual(clonedStoreDb, jsonCfg.storDbCfg) {
|
||||
t.Errorf("Expected %+v, received %+v", utils.ToJSON(clonedStoreDb), utils.ToJSON(jsonCfg.storDbCfg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreDbCfgloadFromJsonCfgPort(t *testing.T) {
|
||||
var dbcfg StorDbCfg
|
||||
cfgJSONStr := `{
|
||||
|
||||
Reference in New Issue
Block a user