mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added test for ActionTiming.Tasks
This commit is contained in:
committed by
Dan Christian Bogos
parent
8aded13e27
commit
3a64f321eb
@@ -62,6 +62,7 @@ func (at *ActionTiming) Tasks() (tsks []*Task) {
|
||||
ActionsID: at.ActionsID,
|
||||
AccountID: acntID,
|
||||
}
|
||||
i++
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user