mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
return error on action execute api
This commit is contained in:
@@ -212,9 +212,9 @@ func (self *ApierV1) EnableDisableBalance(attr *AttrAddBalance, reply *string) e
|
||||
}
|
||||
|
||||
func (self *ApierV1) ExecuteAction(attr *utils.AttrExecuteAction, reply *string) error {
|
||||
tag := fmt.Sprintf("%s:%s", attr.Tenant, attr.Account)
|
||||
accId := utils.AccountKey(attr.Tenant, attr.Account)
|
||||
at := &engine.ActionPlan{
|
||||
AccountIds: []string{tag},
|
||||
AccountIds: []string{accId},
|
||||
ActionsId: attr.ActionsId,
|
||||
}
|
||||
if err := at.Execute(); err != nil {
|
||||
|
||||
@@ -323,6 +323,7 @@ func (at *ActionPlan) Execute() (err error) {
|
||||
}, 0, at.AccountIds...)
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Error executing action plan: %v", err))
|
||||
return err
|
||||
}
|
||||
storageLogger.LogActionPlan(utils.SCHED_SOURCE, at, aac)
|
||||
return
|
||||
|
||||
@@ -21,6 +21,7 @@ package engine
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -1350,6 +1351,24 @@ func TestActionTransactionBalanceType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestActionExecuteActionNonExistingAccount(t *testing.T) {
|
||||
at := &ActionPlan{
|
||||
AccountIds: []string{"cgrates.org:exe"},
|
||||
Timing: &RateInterval{},
|
||||
actions: []*Action{
|
||||
&Action{
|
||||
ActionType: TOPUP,
|
||||
BalanceType: utils.MONETARY,
|
||||
Balance: &Balance{Value: 1.1},
|
||||
},
|
||||
},
|
||||
}
|
||||
err = at.Execute()
|
||||
if err == nil {
|
||||
log.Print("Fail to return error on action execute: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
/**************** Benchmarks ********************************/
|
||||
|
||||
func BenchmarkUUID(b *testing.B) {
|
||||
|
||||
Reference in New Issue
Block a user