mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Tests in console
This commit is contained in:
committed by
Dan Christian Bogos
parent
e5b3b2a73b
commit
64dad8ec54
@@ -1361,3 +1361,8 @@ type DispatcherAccountSv1 struct {
|
||||
func (dR *DispatcherAccountSv1) Ping(args *utils.CGREvent, reply *string) error {
|
||||
return dR.dR.AccountSv1Ping(args, reply)
|
||||
}
|
||||
|
||||
func (rS *DispatcherSv1) Ping(ign *utils.CGREvent, reply *string) error {
|
||||
*reply = utils.Pong
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func TestCmdPingChargerSLow(t *testing.T) {
|
||||
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])
|
||||
m, ok := reflect.TypeOf(new(v1.ChargerSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
|
||||
if !ok {
|
||||
t.Fatal("method not found")
|
||||
}
|
||||
@@ -130,3 +130,514 @@ func TestCmdPingChargerSLow(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCmdPingResourcesLow(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.ResourcesLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.ResourceSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.ResourceSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.ResourceSv1)).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 TestCmdPingStatServiceLow(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.StatServiceLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.StatSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.StatSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.StatSv1)).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 TestCmdPingThresholdsLow(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.ThresholdsLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.ThresholdSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.ThresholdSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.ThresholdSv1)).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 TestCmdPingSessionsLow(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.SessionsLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.SessionSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.SessionSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.SessionSv1)).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 TestCmdPingLoaderSLow(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.LoaderSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.LoaderSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.LoaderSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.LoaderSv1)).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 TestCmdPingDispatcherSLow(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.DispatcherSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.DispatcherSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.DispatcherSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.DispatcherSv1)).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 TestCmdPingAnalyzerSLow(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.AnalyzerSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.AnalyzerSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.AnalyzerSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.AnalyzerSv1)).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 TestCmdPingSchedulerSLow(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.SchedulerSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.SchedulerSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.SchedulerSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.SchedulerSv1)).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 TestCmdPingRALsLow(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.RALsLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.RALsV1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.RALsV1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.RALsV1)).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 TestCmdPingReplicatorLow(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.ReplicatorLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.ReplicatorSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.RALsV1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.ReplicatorSv1)).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 TestCmdPingApierSLow(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.ApierSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.APIerSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.APIerSv1Ping, result2)
|
||||
}
|
||||
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 ")
|
||||
}
|
||||
// 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 TestCmdPingEEsLow(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.EEsLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.EeSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.EeSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.EeSv1)).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 TestCmdPingRateSLow(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.RateSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.RateSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.RateSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.RateSv1)).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 TestCmdPingAccountSLow(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.AccountSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.AccountSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.AccountSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.AccountSv1)).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 TestCmdPingActionSLow(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.ActionSLow
|
||||
result2 := command.RpcMethod()
|
||||
if !reflect.DeepEqual(result2, utils.ActionSv1Ping) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", utils.ActionSv1Ping, result2)
|
||||
}
|
||||
m, ok := reflect.TypeOf(new(v1.ActionSv1)).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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user