diff --git a/console/accounts_test.go b/console/accounts_test.go index 67218c5c1..0f794a143 100644 --- a/console/accounts_test.go +++ b/console/accounts_test.go @@ -51,4 +51,15 @@ func TestCmdAccounts(t *testing.T) { if err := command.PostprocessRpcParams(); err != nil { t.Fatal(err) } + // for coverage purpose + formatedResult := command.GetFormatedResult(command.RpcResult()) + expected := GetFormatedResult(command.RpcResult(), utils.StringSet{ + utils.Usage: {}, + utils.GroupIntervalStart: {}, + utils.RateIncrement: {}, + utils.RateUnit: {}, + }) + if !reflect.DeepEqual(formatedResult, expected) { + t.Errorf("Expected <%+v>, Received <%+v>", expected, formatedResult) + } } diff --git a/console/active_sessions_test.go b/console/active_sessions_test.go index f8207438d..cd3880748 100644 --- a/console/active_sessions_test.go +++ b/console/active_sessions_test.go @@ -51,4 +51,15 @@ func TestCmdActiveSessions(t *testing.T) { if err := command.PostprocessRpcParams(); err != nil { t.Fatal(err) } + // for coverage purpose + formatedResult := command.GetFormatedResult(command.RpcResult()) + expected := GetFormatedSliceResult(command.RpcResult(), utils.StringSet{ + utils.Usage: {}, + utils.DurationIndex: {}, + utils.MaxRateUnit: {}, + utils.DebitInterval: {}, + }) + if !reflect.DeepEqual(formatedResult, expected) { + t.Errorf("Expected <%+v>, Received <%+v>", expected, formatedResult) + } } diff --git a/console/attributes_process_event_test.go b/console/attributes_process_event_test.go index 71707d61a..90b5d1c1f 100644 --- a/console/attributes_process_event_test.go +++ b/console/attributes_process_event_test.go @@ -51,4 +51,12 @@ func TestCmdAttributesProcessEvent(t *testing.T) { if err := command.PostprocessRpcParams(); err != nil { t.Fatal(err) } + // for coverage purpose + formatedResult := command.GetFormatedResult(command.RpcResult()) + expected := GetFormatedResult(command.RpcResult(), utils.StringSet{ + utils.Usage: {}, + }) + if !reflect.DeepEqual(formatedResult, expected) { + t.Errorf("Expected <%+v>, Received <%+v>", expected, formatedResult) + } } diff --git a/console/chargers_process_event_test.go b/console/chargers_process_event_test.go index 715289a99..a9246c1f3 100644 --- a/console/chargers_process_event_test.go +++ b/console/chargers_process_event_test.go @@ -50,4 +50,13 @@ func TestCmdChargersProcessEvent(t *testing.T) { if err := command.PostprocessRpcParams(); err != nil { t.Fatal(err) } + // for coverage purpose + formatedResult := command.GetFormatedResult(command.RpcResult()) + expected := GetFormatedResult(command.RpcResult(), utils.StringSet{ + utils.Usage: {}, + }) + if !reflect.DeepEqual(formatedResult, expected) { + t.Errorf("Expected <%+v>, Received <%+v>", expected, formatedResult) + } + } diff --git a/console/compute_actionplan_indexes_test.go b/console/compute_actionplan_indexes_test.go index deb7ecc24..f16d4f1d1 100644 --- a/console/compute_actionplan_indexes_test.go +++ b/console/compute_actionplan_indexes_test.go @@ -18,7 +18,6 @@ along with this program. If not, see package console -//willfix /* func TestCmdComputeActionPlanIndexes(t *testing.T) { // commands map is initiated in init function @@ -31,8 +30,7 @@ func TestCmdComputeActionPlanIndexes(t *testing.T) { if m.Type.NumIn() != 3 { // ApierSv1 is consider and we expect 3 inputs t.Fatalf("invalid number of input parameters ") } - fmt.Println(m.Type.In(1)) - fmt.Println(reflect.TypeOf(command.RpcParams(true))) + // verify the type of input parameter if ok := m.Type.In(1).AssignableTo(reflect.TypeOf(command.RpcParams(true))); !ok { t.Fatalf("cannot assign input parameter") diff --git a/console/cost_test.go b/console/cost_test.go index 948300da6..9bb44a2d4 100644 --- a/console/cost_test.go +++ b/console/cost_test.go @@ -50,4 +50,21 @@ func TestCmdCost(t *testing.T) { if err := command.PostprocessRpcParams(); err != nil { t.Fatal(err) } + // for coverage purpose + formatedResult := command.GetFormatedResult(command.RpcResult()) + expected := GetFormatedResult(command.RpcResult(), utils.StringSet{ + utils.Usage: {}, + utils.GroupIntervalStart: {}, + utils.RateIncrement: {}, + utils.RateUnit: {}, + }) + if !reflect.DeepEqual(formatedResult, expected) { + t.Errorf("Expected <%+v>, Received <%+v>", expected, formatedResult) + } + // for coverage purpose + result := command.ClientArgs() + expected2 := []string{utils.Tenant, utils.Category, utils.Subject, utils.AnswerTime, utils.Destination, utils.Usage} + if !reflect.DeepEqual(result, expected2) { + t.Errorf("Expected <%+v>, Received <%+v>", expected2, result) + } } diff --git a/console/ratingprofile_remove_test.go b/console/ratingprofile_remove_test.go index f839b43b0..c3da0a2a9 100644 --- a/console/ratingprofile_remove_test.go +++ b/console/ratingprofile_remove_test.go @@ -18,7 +18,15 @@ along with this program. If not, see package console -/* +import ( + "reflect" + "strings" + "testing" + + v1 "github.com/cgrates/cgrates/apier/v1" + "github.com/cgrates/cgrates/utils" +) + func TestCmdRatingPlanRem(t *testing.T) { // commands map is initiated in init function command := commands["ratingprofile_remove"] @@ -38,9 +46,36 @@ func TestCmdRatingPlanRem(t *testing.T) { if ok := m.Type.In(2).AssignableTo(reflect.TypeOf(command.RpcResult())); !ok { t.Fatalf("cannot assign output parameter") } - // for coverage purpose - if err := command.PostprocessRpcParams(); err != nil { + +} + +func TestCmdRatingPlanRemPostprocessRpcParams(t *testing.T) { + testStruct := CmdRemRatingProfile{ + name: "", + rpcMethod: "", + rpcParams: nil, + rpcResult: "", + CommandExecuter: nil, + } + + if err := testStruct.PostprocessRpcParams(); err != nil { t.Fatal(err) } } -*/ + +func TestCmdRatingPlanRemPostprocessRpcParamsError(t *testing.T) { + testStruct := CmdRemRatingProfile{ + name: "", + rpcMethod: "", + rpcParams: &v1.AttrRemoveRatingProfile{}, + rpcResult: "", + CommandExecuter: nil, + } + + err := testStruct.PostprocessRpcParams() + + if err == nil || err != utils.ErrMandatoryIeMissing { + t.Fatal(err) + } + +} diff --git a/console/stordb_versions_test.go b/console/stordb_versions_test.go index fe2150718..8a6cab6f4 100644 --- a/console/stordb_versions_test.go +++ b/console/stordb_versions_test.go @@ -18,7 +18,6 @@ along with this program. If not, see package console -//willfix /* func TestCmdStorDBVersions(t *testing.T) { // commands map is initiated in init function @@ -31,8 +30,6 @@ func TestCmdStorDBVersions(t *testing.T) { if m.Type.NumIn() != 3 { // ApierSv1 is consider and we expect 3 inputs t.Fatalf("invalid number of input parameters ") } - fmt.Println(m.Type.In(1)) - fmt.Println(reflect.TypeOf(command.RpcParams(true))) // verify the type of input parameter if ok := m.Type.In(1).AssignableTo(reflect.TypeOf(command.RpcParams(true))); !ok { t.Fatalf("cannot assign input parameter") diff --git a/console/threshold_test.go b/console/threshold_test.go index 3e888d3a5..be094518e 100644 --- a/console/threshold_test.go +++ b/console/threshold_test.go @@ -50,4 +50,5 @@ func TestCmdThreshold(t *testing.T) { if err := command.PostprocessRpcParams(); err != nil { t.Fatal(err) } + }