Added test for ActionTiming.Tasks

This commit is contained in:
adragusin
2019-11-07 13:59:20 +02:00
committed by Dan Christian Bogos
parent 8aded13e27
commit 3a64f321eb
3 changed files with 26 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ func (at *ActionTiming) Tasks() (tsks []*Task) {
ActionsID: at.ActionsID,
AccountID: acntID,
}
i++
}
return
}

View File

@@ -19,11 +19,35 @@ package engine
import (
"reflect"
"sort"
"testing"
"github.com/cgrates/cgrates/utils"
)
func TestActionTimingTasks(t *testing.T) {
//empty check
actionTiming := new(ActionTiming)
eOut := []*Task{&Task{Uuid: "", ActionsID: ""}}
rcv := actionTiming.Tasks()
if !reflect.DeepEqual(eOut, rcv) {
t.Errorf("Expecting: %+v, received: %+v", eOut, rcv)
}
//multiple check
actionTiming.ActionsID = "test"
actionTiming.Uuid = "test"
actionTiming.accountIDs = utils.StringMap{"1001": true, "1002": true, "1003": true}
eOut = []*Task{
&Task{Uuid: "test", AccountID: "1001", ActionsID: "test"},
&Task{Uuid: "test", AccountID: "1002", ActionsID: "test"},
&Task{Uuid: "test", AccountID: "1003", ActionsID: "test"},
}
rcv = actionTiming.Tasks()
sort.Slice(rcv, func(i, j int) bool { return rcv[i].AccountID < rcv[j].AccountID })
if !reflect.DeepEqual(eOut, rcv) {
t.Errorf("Expecting: %+v, received: %+v", eOut, rcv)
}
}
func TestActionPlanClone(t *testing.T) {
at1 := &ActionPlan{
Id: "test",

View File

@@ -445,7 +445,7 @@ func TestActionPlanFunctionNotAvailable(t *testing.T) {
actions: []*Action{a},
}
err := at.Execute(nil, nil)
if err != utils.ErrPartiallyExecuted { // because we want to return err if we can't execute all actions
if err != utils.ErrPartiallyExecuted { // because we want to return err if we can't execute all actions
t.Errorf("Faild to detect wrong function type: %v", err)
}
}