return error on action execute api

This commit is contained in:
Radu Ioan Fericean
2015-11-11 22:03:49 +02:00
parent c68332929b
commit 5aef2fa85d
3 changed files with 22 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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) {