Improving coverage at config

This commit is contained in:
arberkatellari
2022-12-01 08:02:34 -05:00
committed by Dan Christian Bogos
parent cef7de30d8
commit 0539893157
2 changed files with 29 additions and 14 deletions

View File

@@ -1128,21 +1128,22 @@ func TestCGRConfigTpeSCfg(t *testing.T) {
}
}
// unfinished
// func TestCGRConfigV1StoreCfgInDB(t *testing.T) {
func TestCGRConfigV1StoreCfgInDB(t *testing.T) {
// cfg := NewDefaultCGRConfig()
// cfg.rldCh = make(chan string, 100)
// db := make(CgrJsonCfg)
// cfg.db = db
cfg := NewDefaultCGRConfig()
cfg.rldCh = make(chan string, 100)
cfg.db = &mockDb{
GetSectionF: func(ctx *context.Context, s string, i interface{}) error { return nil },
SetSectionF: func(ctx *context.Context, s string, i interface{}) error { return utils.ErrNotImplemented },
}
// args := &SectionWithAPIOpts{
// Sections: []string{utils.MetaAll},
// }
args := &SectionWithAPIOpts{
Sections: []string{GeneralJSON},
}
// var reply string
var reply string
// if err := cfg.V1StoreCfgInDB(context.Background(), args, &reply); err == nil || err != nil {
// t.Errorf("Expected %v \n but received \n %v", nil, err)
// }
// }
if err := cfg.V1StoreCfgInDB(context.Background(), args, &reply); err == nil || err != utils.ErrNotImplemented {
t.Errorf("Expected %v \n but received \n %v", utils.ErrNotImplemented, err)
}
}

View File

@@ -6303,3 +6303,17 @@ func TestCGRConfigLoadConfigDBCfgError(t *testing.T) {
t.Errorf("Expected error <%v>, Received error <%v>", utils.ErrNotImplemented, err)
}
}
// unfinished
// func TestLoadConfigFromHTTPErrorNewReqCtx(t *testing.T) {
// cfgCgr := NewDefaultCGRConfig()
// ctx := context.Background()
// url := "https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/multifiles/a.json"
// expected := "parse \"inexistentURL\": invalid URI for request"
// if err := loadConfigFromHTTP(ctx, url, cfgCgr.sections, nil); err == nil || err.Error() != expected {
// t.Errorf("Expected %+v, received %+v", expected, err)
// }
// }