mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Coverage tests in console
This commit is contained in:
committed by
Dan Christian Bogos
parent
4a886761bc
commit
2ce9c97d28
@@ -353,10 +353,27 @@ func TestCommandExecuterClientArgs(t *testing.T) {
|
||||
testStruct := &CommandExecuter{}
|
||||
testStruct.command = commands["accounts"]
|
||||
result := testStruct.clientArgs(testStruct.command.RpcParams(true))
|
||||
expected := []string{"Filter", "Limit", "Offset", "AccountIDs", "Tenant"}
|
||||
sort.Slice(result, func(i, j int) bool {
|
||||
return true
|
||||
})
|
||||
expected := []string{"AccountIDs", "Filter", "Limit", "Offset", "Tenant"}
|
||||
sort.Strings(result)
|
||||
if !reflect.DeepEqual(expected, result) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
type mockTest struct {
|
||||
a int
|
||||
B *bool
|
||||
C struct {
|
||||
}
|
||||
D time.Time
|
||||
}
|
||||
|
||||
func TestCommandExecuterClientArgsCase(t *testing.T) {
|
||||
testStruct := &CommandExecuter{}
|
||||
testStruct.command = commands["accounts"]
|
||||
result := testStruct.clientArgs(new(mockTest))
|
||||
expected := []string{"B", "D"}
|
||||
sort.Strings(result)
|
||||
if !reflect.DeepEqual(expected, result) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", expected, result)
|
||||
}
|
||||
|
||||
@@ -125,11 +125,13 @@ func TestCmdParseLocalExecuteCase5(t *testing.T) {
|
||||
// for coverage purpose
|
||||
testStruct := &CmdParse{
|
||||
rpcParams: &AttrParse{
|
||||
Expression: "~test_exp",
|
||||
Value: "~test_value",
|
||||
Expression: "~*req.Field{*duration}",
|
||||
Value: "a",
|
||||
},
|
||||
}
|
||||
|
||||
testStruct.LocalExecute()
|
||||
|
||||
expected := "time: invalid duration \"a\""
|
||||
received := testStruct.LocalExecute()
|
||||
if !reflect.DeepEqual(received, expected) {
|
||||
t.Errorf("Expected <%+v>, Received <%+v>", expected, received)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user