mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
ResetAccountActionTriggers has Executed attribute
This commit is contained in:
@@ -129,7 +129,15 @@ func (self *ApierV1) RemoveAccountActionTriggers(attr AttrRemoveAccountActionTri
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *ApierV1) ResetAccountActionTriggers(attr AttrRemoveAccountActionTriggers, reply *string) error {
|
||||
type AttrResetAccountActionTriggers struct {
|
||||
Tenant string
|
||||
Account string
|
||||
GroupID string
|
||||
UniqueID string
|
||||
Executed bool
|
||||
}
|
||||
|
||||
func (self *ApierV1) ResetAccountActionTriggers(attr AttrResetAccountActionTriggers, reply *string) error {
|
||||
|
||||
if missing := utils.MissingStructFields(&attr, []string{"Tenant", "Account"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
@@ -146,11 +154,13 @@ func (self *ApierV1) ResetAccountActionTriggers(attr AttrRemoveAccountActionTrig
|
||||
if (attr.UniqueID == "" || at.UniqueID == attr.UniqueID) &&
|
||||
(attr.GroupID == "" || at.ID == attr.GroupID) {
|
||||
// reset action trigger
|
||||
at.Executed = false
|
||||
at.Executed = attr.Executed
|
||||
}
|
||||
|
||||
}
|
||||
account.ExecuteActionTriggers(nil)
|
||||
if attr.Executed == false {
|
||||
account.ExecuteActionTriggers(nil)
|
||||
}
|
||||
if err := self.AccountDb.SetAccount(account); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -366,3 +366,32 @@ func TestTpRemActionsRefenced(t *testing.T) {
|
||||
t.Error("no error on ApierV2.GetActions: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierResetAccountActionTriggers(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1005"}
|
||||
if err := tpRPC.Call("ApierV2.GetAccount", attrs, &acnt); err != nil {
|
||||
t.Error(err)
|
||||
} else if acnt.ActionTriggers[0].Executed == true {
|
||||
t.Errorf("wrong action trigger executed flag: %s", utils.ToIJSON(acnt.ActionTriggers))
|
||||
}
|
||||
var reply string
|
||||
if err := tpRPC.Call("ApierV2.ResetAccountActionTriggers", v1.AttrResetAccountActionTriggers{
|
||||
Tenant: "cgrates.org",
|
||||
Account: "1005",
|
||||
GroupID: "STANDARD_TRIGGERS",
|
||||
Executed: true,
|
||||
}, &reply); err != nil {
|
||||
t.Error("Error on ApierV2.ResetAccountActionTriggers: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Calling ApierV2.ResetAccountActionTriggers got reply: %s", reply)
|
||||
}
|
||||
if err := tpRPC.Call("ApierV2.GetAccount", attrs, &acnt); err != nil {
|
||||
t.Error(err)
|
||||
} else if acnt.ActionTriggers[0].Executed == false {
|
||||
t.Errorf("wrong action trigger executed flag: %s", utils.ToIJSON(acnt.ActionTriggers))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user