diff --git a/dispatchers/config_it_test.go b/dispatchers/config_it_test.go index 3151f3fc0..c2d94aaff 100644 --- a/dispatchers/config_it_test.go +++ b/dispatchers/config_it_test.go @@ -84,3 +84,138 @@ func testDspConfigSv1GetJSONSection(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(reply)) } } + +func TestDspConfigSv1GetConfigNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + CGREvent := &config.SectionWithAPIOpts{ + Tenant: "tenant", + } + var reply *map[string]interface{} + result := dspSrv.ConfigSv1GetConfig(CGREvent, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1GetConfigErrorNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} + CGREvent := &config.SectionWithAPIOpts{} + var reply *map[string]interface{} + result := dspSrv.ConfigSv1GetConfig(CGREvent, reply) + expected := "MANDATORY_IE_MISSING: [ApiKey]" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1ReloadConfigNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + CGREvent := &config.ReloadArgs{ + Tenant: "tenant", + } + var reply *string + result := dspSrv.ConfigSv1ReloadConfig(CGREvent, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1ReloadConfigErrorNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} + CGREvent := &config.ReloadArgs{} + var reply *string + result := dspSrv.ConfigSv1ReloadConfig(CGREvent, reply) + expected := "MANDATORY_IE_MISSING: [ApiKey]" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1SetConfigNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + CGREvent := &config.SetConfigArgs{ + Tenant: "tenant", + } + var reply *string + result := dspSrv.ConfigSv1SetConfig(CGREvent, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1SetConfigErrorNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} + CGREvent := &config.SetConfigArgs{} + var reply *string + result := dspSrv.ConfigSv1SetConfig(CGREvent, reply) + expected := "MANDATORY_IE_MISSING: [ApiKey]" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1SetConfigFromJSONNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + CGREvent := &config.SetConfigFromJSONArgs{ + Tenant: "tenant", + } + var reply *string + result := dspSrv.ConfigSv1SetConfigFromJSON(CGREvent, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1SetConfigFromJSONErrorNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} + CGREvent := &config.SetConfigFromJSONArgs{} + var reply *string + result := dspSrv.ConfigSv1SetConfigFromJSON(CGREvent, reply) + expected := "MANDATORY_IE_MISSING: [ApiKey]" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1GetConfigAsJSONNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + CGREvent := &config.SectionWithAPIOpts{ + Tenant: "tenant", + } + var reply *string + result := dspSrv.ConfigSv1GetConfigAsJSON(CGREvent, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspConfigSv1GetConfigAsJSONErrorNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} + CGREvent := &config.SectionWithAPIOpts{} + var reply *string + result := dspSrv.ConfigSv1GetConfigAsJSON(CGREvent, reply) + expected := "MANDATORY_IE_MISSING: [ApiKey]" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +}