From 2fec0b3d40e628ae5ad96a7ad7180fb2ac2fd8fa Mon Sep 17 00:00:00 2001 From: andronache Date: Fri, 16 Apr 2021 17:00:44 +0300 Subject: [PATCH] Cover tests in dispatchers --- dispatchers/libdispatcher_test.go | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/dispatchers/libdispatcher_test.go b/dispatchers/libdispatcher_test.go index 34974f97d..db1caf943 100644 --- a/dispatchers/libdispatcher_test.go +++ b/dispatchers/libdispatcher_test.go @@ -718,3 +718,51 @@ func TestLibDispatcherLoadStrategyDispatcherDispatchHostsID(t *testing.T) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) } } + +func TestLibDispatcherLoadStrategyDispatchCaseHosts(t *testing.T) { + wgDsp := &loadStrategyDispatcher{ + hosts: engine.DispatcherHostProfiles{ + { + ID: "testID", + FilterIDs: []string{"filterID"}, + Weight: 4, + Params: map[string]interface{}{ + utils.MetaRatio: 1, + }, + Blocker: false, + }, + }, + defaultRatio: 1, + } + dataDB := engine.NewInternalDB(nil, nil, true) + dM := engine.NewDataManager(dataDB, config.CgrConfig().CacheCfg(), nil) + err := wgDsp.dispatch(dM, "", "", "", []string{"testID"}, "", "", "") + expected := "HOST_NOT_FOUND" + if err == nil || err.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) + } +} + +/* +func TestLibDispatcherLoadStrategyDispatchCaseHostsError(t *testing.T) { + wgDsp := &loadStrategyDispatcher{ + hosts: engine.DispatcherHostProfiles{ + { + ID: "testID", + FilterIDs: []string{"filterID"}, + Weight: 4, + Params: map[string]interface{}{ + utils.MetaRatio: 1, + }, + Blocker: false, + }, + }, + defaultRatio: 1, + } + err := wgDsp.dispatch(nil, "", "", "", []string{"testID"}, "", "", "") + expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION" + if err == nil || err.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) + } +} +*/