From 3863a37ecbf960f1f967ead2d61b37cb34b05f70 Mon Sep 17 00:00:00 2001 From: armirveliaj Date: Thu, 30 May 2024 10:57:48 -0400 Subject: [PATCH] Add unit tests on dispatchers --- dispatchers/responder_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dispatchers/responder_test.go b/dispatchers/responder_test.go index 3a1298965..76ce6bf24 100644 --- a/dispatchers/responder_test.go +++ b/dispatchers/responder_test.go @@ -410,3 +410,32 @@ func TestDspResponderGetMaxSessionTimeOnAccountsErrorNil(t *testing.T) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) } } + +func TestDspResponderGetCostOnRatingPlansNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} + CGREvent := &utils.GetCostOnRatingPlansArgs{ + Tenant: "tenant", + } + var reply *map[string]any + result := dspSrv.ResponderGetCostOnRatingPlans(context.Background(), CGREvent, reply) + expected := "MANDATORY_IE_MISSING: [ApiKey]" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspResponderGetCostOnRatingPlansErrorNil(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + CGREvent := &utils.GetCostOnRatingPlansArgs{ + Tenant: "tenant", + } + var reply *map[string]any + result := dspSrv.ResponderGetCostOnRatingPlans(context.Background(), CGREvent, reply) + expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +}