mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
fixed display of help command for maxusage
This commit is contained in:
committed by
Dan Christian Bogos
parent
e859be8806
commit
40ff69ba40
@@ -19,6 +19,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
package console
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -54,7 +58,10 @@ func (self *CmdGetMaxUsage) RpcMethod() string {
|
||||
|
||||
func (self *CmdGetMaxUsage) RpcParams(reset bool) any {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = new(engine.UsageRecordWithAPIOpts)
|
||||
self.rpcParams = &engine.UsageRecordWithAPIOpts{
|
||||
UsageRecord: new(engine.UsageRecord),
|
||||
APIOpts: make(map[string]any),
|
||||
}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
@@ -64,10 +71,18 @@ func (self *CmdGetMaxUsage) PostprocessRpcParams() error {
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) RpcResult() any {
|
||||
var f int64
|
||||
return &f
|
||||
var d time.Duration
|
||||
return &d
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) ClientArgs() []string {
|
||||
return self.clientArgs
|
||||
}
|
||||
|
||||
func (self *CmdGetMaxUsage) GetFormatedResult(result any) string {
|
||||
if tv, canCast := result.(*time.Duration); canCast {
|
||||
return fmt.Sprintf(`"%s"`, tv.String())
|
||||
}
|
||||
out, _ := json.MarshalIndent(result, utils.EmptyString, " ")
|
||||
return string(out)
|
||||
}
|
||||
|
||||
@@ -53,14 +53,9 @@ func TestCmdMaxUsage(t *testing.T) {
|
||||
}
|
||||
// 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)
|
||||
|
||||
if formatedResult != `"0s"` {
|
||||
t.Errorf("Expected 0s, Received %s", formatedResult)
|
||||
}
|
||||
expected2 := []string{utils.ToR, utils.RequestType, utils.Tenant,
|
||||
utils.Category, utils.AccountField, utils.Subject, utils.Destination,
|
||||
|
||||
Reference in New Issue
Block a user