mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 09:08:45 +05:00
more test fixes
This commit is contained in:
@@ -98,14 +98,14 @@ import (
|
||||
*/
|
||||
|
||||
type AttrsGetScheduledActions struct {
|
||||
Direction, Tenant, Account string
|
||||
TimeStart, TimeEnd time.Time // Filter based on next runTime
|
||||
Tenant, Account string
|
||||
TimeStart, TimeEnd time.Time // Filter based on next runTime
|
||||
utils.Paginator
|
||||
}
|
||||
|
||||
type ScheduledActions struct {
|
||||
NextRunTime time.Time
|
||||
Accounts []*utils.DirectionTenantAccount
|
||||
Accounts []*utils.TenantAccount
|
||||
ActionsId, ActionPlanId, ActionPlanUuid string
|
||||
}
|
||||
|
||||
@@ -142,22 +142,18 @@ func (self *ApierV1) GetScheduledActions(attrs AttrsGetScheduledActions, reply *
|
||||
}
|
||||
acntFiltersMatch := false
|
||||
for _, acntKey := range qActions.AccountIds {
|
||||
directionMatched := len(attrs.Direction) == 0
|
||||
tenantMatched := len(attrs.Tenant) == 0
|
||||
accountMatched := len(attrs.Account) == 0
|
||||
dta, _ := utils.NewDTAFromAccountKey(acntKey)
|
||||
dta, _ := utils.NewTAFromAccountKey(acntKey)
|
||||
sas.Accounts = append(sas.Accounts, dta)
|
||||
// One member matching
|
||||
if !directionMatched && attrs.Direction == dta.Direction {
|
||||
directionMatched = true
|
||||
}
|
||||
if !tenantMatched && attrs.Tenant == dta.Tenant {
|
||||
tenantMatched = true
|
||||
}
|
||||
if !accountMatched && attrs.Account == dta.Account {
|
||||
accountMatched = true
|
||||
}
|
||||
if directionMatched && tenantMatched && accountMatched {
|
||||
if tenantMatched && accountMatched {
|
||||
acntFiltersMatch = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func init() {
|
||||
c := &CmdExecuteAction{
|
||||
name: "action_execute",
|
||||
rpcMethod: "ApierV1.ExecuteAction",
|
||||
rpcParams: &utils.AttrExecuteAction{Direction: utils.OUT},
|
||||
rpcParams: &utils.AttrExecuteAction{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
@@ -50,7 +50,7 @@ func (self *CmdExecuteAction) RpcMethod() string {
|
||||
|
||||
func (self *CmdExecuteAction) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.AttrExecuteAction{Direction: utils.OUT}
|
||||
self.rpcParams = &utils.AttrExecuteAction{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
@@ -146,9 +146,9 @@ func logAction(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) (er
|
||||
|
||||
// Used by cdrLogAction to dynamically parse values out of account and action
|
||||
func parseTemplateValue(rsrFlds utils.RSRFields, acnt *Account, action *Action) string {
|
||||
dta, err := utils.NewDTAFromAccountKey(acnt.Id) // Account information should be valid
|
||||
dta, err := utils.NewTAFromAccountKey(acnt.Id) // Account information should be valid
|
||||
if err != nil {
|
||||
dta = new(utils.DirectionTenantAccount) // Init with empty values
|
||||
dta = new(utils.TenantAccount) // Init with empty values
|
||||
}
|
||||
var parsedValue string // Template values
|
||||
for _, rsrFld := range rsrFlds {
|
||||
@@ -156,7 +156,7 @@ func parseTemplateValue(rsrFlds utils.RSRFields, acnt *Account, action *Action)
|
||||
case "account_id":
|
||||
parsedValue += rsrFld.ParseValue(acnt.Id)
|
||||
case "direction":
|
||||
parsedValue += rsrFld.ParseValue(dta.Direction)
|
||||
parsedValue += rsrFld.ParseValue(action.Balance.Directions.String())
|
||||
case "tenant":
|
||||
parsedValue += rsrFld.ParseValue(dta.Tenant)
|
||||
case "account":
|
||||
|
||||
@@ -1105,7 +1105,7 @@ func TestTutLocalSetAccount(t *testing.T) {
|
||||
t.Errorf("Accounts received: %+v", acnts)
|
||||
} else {
|
||||
acnt := acnts[0]
|
||||
dta, _ := utils.NewDTAFromAccountKey(acnt.Id)
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.Id)
|
||||
if dta.Tenant != attrs.Tenant || dta.Account != attrs.Account {
|
||||
t.Error("Unexpected account id received: ", acnt.Id)
|
||||
}
|
||||
@@ -1134,7 +1134,7 @@ func TestTutLocalSetAccount(t *testing.T) {
|
||||
t.Errorf("Accounts received: %+v", acnts)
|
||||
} else {
|
||||
acnt := acnts[0]
|
||||
dta, _ := utils.NewDTAFromAccountKey(acnt.Id)
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.Id)
|
||||
if dta.Tenant != attrs.Tenant || dta.Account != attrs.Account {
|
||||
t.Error("Unexpected account id received: ", acnt.Id)
|
||||
}
|
||||
|
||||
@@ -804,16 +804,16 @@ type AttrDerivedChargers struct {
|
||||
Direction, Tenant, Category, Account, Subject string
|
||||
}
|
||||
|
||||
func NewDTAFromAccountKey(accountKey string) (*DirectionTenantAccount, error) {
|
||||
func NewTAFromAccountKey(accountKey string) (*TenantAccount, error) {
|
||||
accountSplt := strings.Split(accountKey, CONCATENATED_KEY_SEP)
|
||||
if len(accountSplt) != 3 {
|
||||
return nil, fmt.Errorf("Unsupported format for DirectionTenantAccount: %s", accountKey)
|
||||
if len(accountSplt) != 2 {
|
||||
return nil, fmt.Errorf("Unsupported format for TenantAccount: %s", accountKey)
|
||||
}
|
||||
return &DirectionTenantAccount{accountSplt[0], accountSplt[1], accountSplt[2]}, nil
|
||||
return &TenantAccount{accountSplt[0], accountSplt[1]}, nil
|
||||
}
|
||||
|
||||
type DirectionTenantAccount struct {
|
||||
Direction, Tenant, Account string
|
||||
type TenantAccount struct {
|
||||
Tenant, Account string
|
||||
}
|
||||
|
||||
func NewDTCSFromRPKey(rpKey string) (*DirectionTenantCategorySubject, error) {
|
||||
|
||||
Reference in New Issue
Block a user