diff --git a/config/apis_test.go b/config/apis_test.go index 09a3e74d4..8c59c676b 100644 --- a/config/apis_test.go +++ b/config/apis_test.go @@ -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) + } +} diff --git a/config/config_test.go b/config/config_test.go index ba52f20ae..07602c15f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -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) +// } + +// }