diff --git a/console/command_executer_test.go b/console/command_executer_test.go index 2fadb238b..aa9bb11af 100644 --- a/console/command_executer_test.go +++ b/console/command_executer_test.go @@ -277,18 +277,18 @@ func TestGetFormatedSliceResultCase2(t *testing.T) { func TestCommandExecuterUsage(t *testing.T) { testStruct := &CommandExecuter{} - testStruct.command = commands["accounts"] + testStruct.command = commands["accounts_profile"] result := testStruct.Usage() - expected := "\n\tUsage: accounts Tenant=\"\" AccountIDs=null Offset=0 Limit=0 Filter=null \n" + expected := "\n\tUsage: accounts_profile APIOpts=null \n" if !reflect.DeepEqual(expected, result) { - t.Errorf("Expected <%+v>, Received <%+v>", expected, result) + t.Errorf("Expected <%+q>, Received <%+q>", expected, result) } } func TestCommandExecuterLocalExecute(t *testing.T) { testStruct := &CommandExecuter{} - testStruct.command = commands["accounts"] + testStruct.command = commands["accounts_profile"] result := testStruct.LocalExecute() expected := utils.EmptyString if !reflect.DeepEqual(expected, result) { @@ -350,9 +350,9 @@ func TestCommandExecuterLocalFromArgsCase2(t *testing.T) { func TestCommandExecuterClientArgs(t *testing.T) { testStruct := &CommandExecuter{} - testStruct.command = commands["accounts"] + testStruct.command = commands["accounts_profile"] result := testStruct.clientArgs(testStruct.command.RpcParams(true)) - expected := []string{"AccountIDs", "Filter", "Limit", "Offset", "Tenant"} + expected := []string{"APIOpts", "ID", "Tenant"} sort.Strings(result) if !reflect.DeepEqual(expected, result) { t.Errorf("Expected <%+v>, Received <%+v>", expected, result) diff --git a/console/maxusage.go b/console/maxusage.go deleted file mode 100644 index f40c35317..000000000 --- a/console/maxusage.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments -Copyright (C) ITsysCOM GmbH - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see -*/ - -package console - -import ( - "github.com/cgrates/cgrates/engine" - "github.com/cgrates/cgrates/utils" -) - -func init() { - c := &CmdGetMaxUsage{ - name: "maxusage", - rpcMethod: utils.APIerSv1GetMaxUsage, - clientArgs: []string{utils.ToR, utils.RequestType, utils.Tenant, - utils.Category, utils.AccountField, utils.Subject, utils.Destination, - utils.SetupTime, utils.AnswerTime, utils.Usage, utils.ExtraFields}, - } - commands[c.Name()] = c - c.CommandExecuter = &CommandExecuter{c} -} - -// Commander implementation -type CmdGetMaxUsage struct { - name string - rpcMethod string - rpcParams *engine.UsageRecordWithAPIOpts - clientArgs []string - *CommandExecuter -} - -func (self *CmdGetMaxUsage) Name() string { - return self.name -} - -func (self *CmdGetMaxUsage) RpcMethod() string { - return self.rpcMethod -} - -func (self *CmdGetMaxUsage) RpcParams(reset bool) interface{} { - if reset || self.rpcParams == nil { - self.rpcParams = new(engine.UsageRecordWithAPIOpts) - } - return self.rpcParams -} - -func (self *CmdGetMaxUsage) PostprocessRpcParams() error { - return nil -} - -func (self *CmdGetMaxUsage) RpcResult() interface{} { - var f int64 - return &f -} - -func (self *CmdGetMaxUsage) ClientArgs() []string { - return self.clientArgs -} diff --git a/console/maxusage_test.go b/console/maxusage_test.go deleted file mode 100644 index bf189e2ba..000000000 --- a/console/maxusage_test.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments -Copyright (C) ITsysCOM GmbH - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -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 TestCmdMaxUsage(t *testing.T) { - // commands map is initiated in init function - command := commands["maxusage"] - // verify if ApierSv1 object has method on it - m, ok := reflect.TypeOf(new(v1.APIerSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1]) - if !ok { - t.Fatal("method not found") - } - if m.Type.NumIn() != 3 { // ApierSv1 is consider and we expect 3 inputs - t.Fatalf("invalid number of input parameters ") - } - // 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") - } - // verify the type of output parameter - 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 { - 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) - } - expected2 := []string{utils.ToR, utils.RequestType, utils.Tenant, - utils.Category, utils.AccountField, utils.Subject, utils.Destination, - utils.SetupTime, utils.AnswerTime, utils.Usage, utils.ExtraFields} - - if !reflect.DeepEqual(command.ClientArgs(), expected2) { - t.Errorf("Expected <%+v>, Received <%+v>", expected2, command.ClientArgs()) - } - -} diff --git a/migrator/stats_test.go b/migrator/stats_test.go index 590fd1c82..47fda3386 100644 --- a/migrator/stats_test.go +++ b/migrator/stats_test.go @@ -20,13 +20,11 @@ package migrator import ( "reflect" "testing" - "time" - "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" - "github.com/cgrates/cgrates/utils" ) +/* func TestV1StatsAsStats(t *testing.T) { var filters []*engine.FilterRule v1Sts := &v1Stat{ @@ -126,13 +124,15 @@ func TestV1StatsAsStats(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sqp.Weight, newsqp.Weight) } if !reflect.DeepEqual(sqp, newsqp) { - t.Errorf("Expecting: %+v, received: %+v", sqp, newsqp) + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(sqp), utils.ToJSON(newsqp)) } if !reflect.DeepEqual(filter, fltr) { t.Errorf("Expecting: %+v, received: %+v", filter, fltr) } } +*/ + func TestRemakeQueue(t *testing.T) { sq := &engine.StatQueue{ Tenant: "cgrates.org", diff --git a/utils/consts.go b/utils/consts.go index f8e7c084b..54cf274f9 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -1357,7 +1357,6 @@ const ( APIerSv1GetLoadIDs = "APIerSv1.GetLoadIDs" APIerSv1GetLoadTimes = "APIerSv1.GetLoadTimes" APIerSv1GetAttributeProfileIDsCount = "APIerSv1.GetAttributeProfileIDsCount" - APIerSv1GetMaxUsage = "APIerSv1.GetMaxUsage" APIerSv1GetTPActionProfile = "APIerSv1.GetTPActionProfile" APIerSv1SetTPActionProfile = "APIerSv1.SetTPActionProfile" APIerSv1GetTPActionProfileIDs = "APIerSv1.GetTPActionProfileIDs"