Added an integration test for ActionTriggers in apier

This commit is contained in:
porosnicuadrian
2021-01-08 17:12:40 +02:00
committed by Dan Christian Bogos
parent 17c8a46263
commit a01afde795

View File

@@ -93,6 +93,7 @@ var (
testAPIerSv1GetRatingProfileWithoutTenant,
testAPIerSv1GetRatingProfileIDsWithoutTenant,
testApierReloadCache,
testApierGetActionTrigger,
testApierGetDestination,
testApierGetRatingPlan,
testApierRemoveRatingPlan,
@@ -1013,6 +1014,54 @@ func testAPIerSv1GetRatingProfileWithoutTenant(t *testing.T) {
}
}
func testApierGetActionTrigger(t *testing.T) {
//nothing to get from database
var atrs *engine.ActionTriggers
if err := rater.Call(utils.APIerSv1GetActionTriggers,
&AttrGetActionTriggers{GroupIDs: []string{"TEST_ID1"}}, &atrs); err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
//set an ActionTrigger in database
var reply string
if err := rater.Call(utils.APIerSv1SetActionTrigger,
AttrSetActionTrigger{
GroupID: "TEST_ID1",
UniqueID: "TEST_ID2",
}, &reply); err != nil {
t.Error(err)
}
//get from database and compare
newActTrg := &engine.ActionTriggers{
{
ID: "TEST_ID1",
UniqueID: "TEST_ID2",
Balance: &engine.BalanceFilter{},
},
}
if err := rater.Call(utils.APIerSv1GetActionTriggers,
&AttrGetActionTriggers{GroupIDs: []string{"TEST_ID1"}}, &atrs); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(newActTrg, atrs) {
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(newActTrg), utils.ToJSON(atrs))
}
//remove the ActionTrigger from dataBase
if err := rater.Call(utils.APIerSv1RemoveActionTrigger,
&AttrRemoveActionTrigger{GroupID: "TEST_ID1"}, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Unexpected result")
}
//nothing to get from dataBase
if err := rater.Call(utils.APIerSv1GetActionTriggers,
&AttrGetActionTriggers{GroupIDs: []string{"TEST_ID1"}}, &atrs); err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}
// Test here ReloadCache
func testApierReloadCache(t *testing.T) {
var reply string