mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
Cover funcs from apis/actions.go final
This commit is contained in:
committed by
Dan Christian Bogos
parent
8d47fbc8b5
commit
33cab3f80a
@@ -466,3 +466,59 @@ func TestActionsSv1Ping(t *testing.T) {
|
||||
t.Errorf("Unexpected reply error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestActionsAPIs(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
cfg.GeneralCfg().DefaultCaching = utils.MetaNone
|
||||
data := engine.NewInternalDB(nil, nil, true)
|
||||
dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
|
||||
fltrs := engine.NewFilterS(cfg, nil, dm)
|
||||
|
||||
adms := &AdminSv1{
|
||||
dm: dm,
|
||||
cfg: cfg,
|
||||
}
|
||||
aS := actions.NewActionS(cfg, fltrs, dm, nil)
|
||||
aSv1 := NewActionSv1(aS)
|
||||
|
||||
actPrf := &engine.ActionProfileWithAPIOpts{
|
||||
ActionProfile: &engine.ActionProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "actPrfID",
|
||||
FilterIDs: []string{"*string:~*req.Account:1001"},
|
||||
Actions: []*engine.APAction{
|
||||
{
|
||||
ID: "actID",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var reply string
|
||||
if err := adms.SetActionProfile(context.Background(), actPrf, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
args := &utils.ArgActionSv1ScheduleActions{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1001",
|
||||
},
|
||||
ID: "EventTest",
|
||||
},
|
||||
ActionProfileIDs: []string{"actPrfID"},
|
||||
}
|
||||
|
||||
if err := aSv1.ScheduleActions(context.Background(), args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.OK, reply)
|
||||
}
|
||||
|
||||
if err := aSv1.ExecuteActions(context.Background(), args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.OK, reply)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user