diff --git a/console/compute_actionplan_indexes_test.go b/console/compute_actionplan_indexes_test.go
index f16d4f1d1..9851d1fae 100644
--- a/console/compute_actionplan_indexes_test.go
+++ b/console/compute_actionplan_indexes_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 TestCmdComputeActionPlanIndexes(t *testing.T) {
// commands map is initiated in init function
command := commands["compute_actionplan_indexes"]
@@ -31,9 +39,10 @@ func TestCmdComputeActionPlanIndexes(t *testing.T) {
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")
+ // for coverage purpose
+ result := command.RpcParams(true)
+ if !reflect.DeepEqual(result, new(EmptyWrapper)) {
+ t.Errorf("Expected <%T>, Received <%T>", new(EmptyWrapper), result)
}
// verify the type of output parameter
if ok := m.Type.In(2).AssignableTo(reflect.TypeOf(command.RpcResult())); !ok {
@@ -44,4 +53,3 @@ func TestCmdComputeActionPlanIndexes(t *testing.T) {
t.Fatal(err)
}
}
-*/
diff --git a/console/ping_test.go b/console/ping_test.go
new file mode 100644
index 000000000..56010d9ff
--- /dev/null
+++ b/console/ping_test.go
@@ -0,0 +1,132 @@
+/*
+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 TestCmdPingRoutesLow(t *testing.T) {
+ // commands map is initiated in init function
+ command := commands["ping"]
+ castCommand, canCast := command.(*CmdApierPing)
+ if !canCast {
+ t.Fatalf("cannot cast")
+ }
+ castCommand.item = utils.RoutesLow
+ result2 := command.RpcMethod()
+ if !reflect.DeepEqual(result2, utils.RouteSv1Ping) {
+ t.Errorf("Expected <%+v>, Received <%+v>", utils.RouteSv1Ping, result2)
+ }
+ m, ok := reflect.TypeOf(new(v1.RouteSv1)).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 ")
+ }
+ // for coverage purpose
+ result := command.RpcParams(true)
+ if !reflect.DeepEqual(result, new(StringWrapper)) {
+ t.Errorf("Expected <%T>, Received <%T>", new(StringWrapper), result)
+ }
+ // 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)
+ }
+}
+
+func TestCmdPingAttributesLow(t *testing.T) {
+ // commands map is initiated in init function
+ command := commands["ping"]
+ castCommand, canCast := command.(*CmdApierPing)
+ if !canCast {
+ t.Fatalf("cannot cast")
+ }
+ castCommand.item = utils.AttributesLow
+ result2 := command.RpcMethod()
+ if !reflect.DeepEqual(result2, utils.AttributeSv1Ping) {
+ t.Errorf("Expected <%+v>, Received <%+v>", utils.AttributeSv1Ping, result2)
+ }
+ m, ok := reflect.TypeOf(new(v1.AttributeSv1)).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 ")
+ }
+ // for coverage purpose
+ result := command.RpcParams(true)
+ if !reflect.DeepEqual(result, new(StringWrapper)) {
+ t.Errorf("Expected <%T>, Received <%T>", new(StringWrapper), result)
+ }
+ // 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)
+ }
+
+}
+
+func TestCmdPingChargerSLow(t *testing.T) {
+ // commands map is initiated in init function
+ command := commands["ping"]
+ castCommand, canCast := command.(*CmdApierPing)
+ if !canCast {
+ t.Fatalf("cannot cast")
+ }
+ castCommand.item = utils.ChargerSLow
+ result2 := command.RpcMethod()
+ if !reflect.DeepEqual(result2, utils.ChargerSv1Ping) {
+ t.Errorf("Expected <%+v>, Received <%+v>", utils.ChargerSv1Ping, result2)
+ }
+ m, ok := reflect.TypeOf(new(v1.AttributeSv1)).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 ")
+ }
+ // for coverage purpose
+ result := command.RpcParams(true)
+ if !reflect.DeepEqual(result, new(StringWrapper)) {
+ t.Errorf("Expected <%T>, Received <%T>", new(StringWrapper), result)
+ }
+ // 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)
+ }
+
+}
diff --git a/console/sleep.go b/console/sleep.go
index de02f053e..6c02f23d6 100644
--- a/console/sleep.go
+++ b/console/sleep.go
@@ -18,9 +18,7 @@ along with this program. If not, see
package console
-import (
- "github.com/cgrates/cgrates/utils"
-)
+import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdSleep{
diff --git a/console/sleep_test.go b/console/sleep_test.go
index 3821ce2b1..561b2b196 100644
--- a/console/sleep_test.go
+++ b/console/sleep_test.go
@@ -64,7 +64,7 @@ func TestCmdSleepPostprocessRpcParamsCase2(t *testing.T) {
err := testStruct.PostprocessRpcParams()
if err == nil || err.Error() != "time: invalid duration \"test_item\"" {
- t.Errorf("Expected , Received <%T>", err)
+ t.Errorf("Expected , Received <%+v>", err)
}
}