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
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
// Returns MaxUsage (for calls in seconds), -1 for no limit
|
||||
func (apierSv1 *APIerSv1) GetMaxUsage(ctx *context.Context, usageRecord *engine.UsageRecordWithAPIOpts, maxUsage *int64) error {
|
||||
func (apierSv1 *APIerSv1) GetMaxUsage(ctx *context.Context, usageRecord *engine.UsageRecordWithAPIOpts, maxUsage *time.Duration) error {
|
||||
if apierSv1.Responder == nil {
|
||||
return utils.NewErrNotConnected(utils.RALService)
|
||||
}
|
||||
@@ -70,6 +70,6 @@ func (apierSv1 *APIerSv1) GetMaxUsage(ctx *context.Context, usageRecord *engine.
|
||||
*maxUsage = -1
|
||||
return nil
|
||||
}
|
||||
*maxUsage = maxDur.Nanoseconds()
|
||||
*maxUsage = maxDur
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -230,8 +230,8 @@ cgrates.org,ResGroup21,*string:~*req.Account:1001,2014-07-29T15:00:00Z,1s,2,call
|
||||
cgrates.org,ResGroup22,*string:~*req.Account:dan,2014-07-29T15:00:00Z,3600s,2,premium_call,true,true,10,
|
||||
`
|
||||
IPsCSVContent = `
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],TTL[4],Type[5],AddressPool[6],Allocation[7],Stored[8],Weight[9]
|
||||
cgrates.org,IPs1,*string:~*req.Account:1001,2014-07-29T15:00:00Z,-1,ipv4,127.0.0.1/24,*ascending,true,10
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],TTL[4],Stored[5],Weight[6],PoolID[7],PoolFilterIDs[8],PoolType[9],PoolRange[10],PoolStrategy[11],PoolMessage[12],PoolWeight[13],PoolBlocker[14]
|
||||
cgrates.org,IPs1,*string:~*req.Account:1001,2014-07-29T15:00:00Z,-1,true,10,Pool1,,ipv4,127.0.0.1/24,*ascending,,10,false
|
||||
`
|
||||
StatsCSVContent = `
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],QueueLength[4],TTL[5],MinItems[6],Metrics[7],MetricFilterIDs[8],Stored[9],Blocker[10],Weight[11],ThresholdIDs[12]
|
||||
|
||||
Reference in New Issue
Block a user