mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Coverage in console
This commit is contained in:
committed by
Dan Christian Bogos
parent
ce91a404b2
commit
8b94da6bed
@@ -27,7 +27,7 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestCmdComputeActionPlanIndexes(t *testing.T) {
|
||||
func TestCmdComputeFilterIndexes(t *testing.T) {
|
||||
// commands map is initiated in init function
|
||||
command := commands["compute_filter_indexes"]
|
||||
// verify if ApierSv1 object has method on it
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package console
|
||||
|
||||
//willfix
|
||||
/*
|
||||
func TestCmdLoadIDs(t *testing.T) {
|
||||
// commands map is initiated in init function
|
||||
|
||||
@@ -62,7 +62,7 @@ func (self *CmdPassiveSessions) PostprocessRpcParams() error {
|
||||
}
|
||||
|
||||
func (self *CmdPassiveSessions) RpcResult() interface{} {
|
||||
var sessions *[]*sessions.ExternalSession
|
||||
var sessions []*sessions.ExternalSession
|
||||
return &sessions
|
||||
}
|
||||
|
||||
|
||||
54
console/passive_sessions_test.go
Normal file
54
console/passive_sessions_test.go
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
v1 "github.com/cgrates/cgrates/apier/v1"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestCmdPassiveSessions(t *testing.T) {
|
||||
// commands map is initiated in init function
|
||||
command := commands["passive_sessions"]
|
||||
// verify if ApierSv1 object has method on it
|
||||
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 ")
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestCmdStorDBVersions(t *testing.T) {
|
||||
func TestCmdSetStorDBVersions(t *testing.T) {
|
||||
// commands map is initiated in init function
|
||||
command := commands["set_stordb_versions"]
|
||||
// verify if ApierSv1 object has method on it
|
||||
|
||||
49
console/sharedgroup_test.go
Normal file
49
console/sharedgroup_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
//willfix
|
||||
/*
|
||||
func TestCmdSharedGroup(t *testing.T) {
|
||||
// commands map is initiated in init function
|
||||
command := commands["sharedgroup"]
|
||||
// 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 ")
|
||||
}
|
||||
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")
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ func (cmd *CmdSleep) RpcMethod() string {
|
||||
|
||||
func (cmd *CmdSleep) RpcParams(reset bool) interface{} {
|
||||
if reset || cmd.rpcParams == nil {
|
||||
cmd.rpcParams = &StringWrapper{}
|
||||
cmd.rpcParams = &utils.DurationArgs{}
|
||||
}
|
||||
return cmd.rpcParams
|
||||
}
|
||||
@@ -64,6 +64,6 @@ func (cmd *CmdSleep) PostprocessRpcParams() (err error) {
|
||||
}
|
||||
|
||||
func (cmd *CmdSleep) RpcResult() interface{} {
|
||||
var s *string
|
||||
var s string
|
||||
return &s
|
||||
}
|
||||
|
||||
53
console/sleep_test.go
Normal file
53
console/sleep_test.go
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
v1 "github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestCmdSleep(t *testing.T) {
|
||||
// commands map is initiated in init function
|
||||
command := commands["sleep"]
|
||||
// verify if ApierSv1 object has method on it
|
||||
m, ok := reflect.TypeOf(new(v1.CoreSv1)).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)
|
||||
}
|
||||
}
|
||||
49
console/stordb_versions_test.go
Normal file
49
console/stordb_versions_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
//willfix
|
||||
/*
|
||||
func TestCmdStorDBVersions(t *testing.T) {
|
||||
// commands map is initiated in init function
|
||||
command := commands["stordb_versions"]
|
||||
// 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 ")
|
||||
}
|
||||
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")
|
||||
}
|
||||
// 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