From 077d916a1d7bbdb7dc7d4b998da3fc77f28f3e9f Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 9 Nov 2020 12:04:36 +0200 Subject: [PATCH] Updated unit tests --- config/config_test.go | 11 ++--------- cores/caps_test.go | 4 ++++ engine/z_onstor_it_test.go | 1 - 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index 86dfe630f..b174db076 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -4947,7 +4947,7 @@ func TestV1GetConfigAsJSONRals(t *testing.T) { func TestV1GetConfigAsJSONScheduler(t *testing.T) { var reply string - expected := `{"schedulers":{"cdrs_conns":[],"enabled":false,"filters":[]}}` + expected := `{"schedulers":{"cdrs_conns":[],"enabled":false,"filters":[],"thresholds_conns":[]}}` if cfgCgr, err := NewDefaultCGRConfig(); err != nil { t.Error(err) } else if err := cfgCgr.V1GetConfigAsJSON(&SectionWithOpts{Section: SCHEDULER_JSN}, &reply); err != nil { @@ -4959,7 +4959,7 @@ func TestV1GetConfigAsJSONScheduler(t *testing.T) { func TestV1GetConfigAsJSONCdrs(t *testing.T) { var reply string - expected := `{"schedulers":{"cdrs_conns":[],"enabled":false,"filters":[]}}` + expected := `{"schedulers":{"cdrs_conns":[],"enabled":false,"filters":[],"thresholds_conns":[]}}` if cfgCgr, err := NewDefaultCGRConfig(); err != nil { t.Error(err) } else if err := cfgCgr.V1GetConfigAsJSON(&SectionWithOpts{Section: SCHEDULER_JSN}, &reply); err != nil { @@ -5053,13 +5053,6 @@ func TestV1GetConfigAsJSONDNSAgent(t *testing.T) { } } -func TestNewCGRConfigFromPathError(t *testing.T) { - expected := "file :NOT_FOUND:ENV_VAR:LOGGER" - if _, err := NewCGRConfigFromPath("/usr/share/cgrates/conf/samples/multifiles"); err == nil || err.Error() != expected { - t.Errorf("Expected %+v, received %+v", expected, err) - } -} - func TestCgrCdfEventReader(t *testing.T) { eCfg := &ERsCfg{ Enabled: false, diff --git a/cores/caps_test.go b/cores/caps_test.go index a0d5d66ad..d84f8e858 100644 --- a/cores/caps_test.go +++ b/cores/caps_test.go @@ -22,6 +22,7 @@ import ( "net/rpc" "net/rpc/jsonrpc" "reflect" + "runtime" "testing" "time" @@ -73,7 +74,9 @@ func TestCapsStats(t *testing.T) { t.Errorf("Expected: %v ,received: %v", exp, cs) } <-exitChan + exitChan = make(chan bool, 1) go func() { + runtime.Gosched() time.Sleep(100) exitChan <- true }() @@ -87,6 +90,7 @@ func TestCapsStats(t *testing.T) { if pk := cs.GetPeak(); pk != 2 { t.Errorf("Expected the peak to be 2 received: %v", pk) } + <-exitChan } func TestCapsStatsGetAverage(t *testing.T) { diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go index f39f73d0a..5d684fb94 100644 --- a/engine/z_onstor_it_test.go +++ b/engine/z_onstor_it_test.go @@ -1378,7 +1378,6 @@ func testOnStorITCRUDHistory(t *testing.T) { func testOnStorITCRUDStructVersion(t *testing.T) { if vrst, err := onStor.DataDB().GetVersions(utils.Accounts); err != utils.ErrNotFound { - fmt.Println(vrst) t.Error(err) } vrs := Versions{