diff --git a/data/tariffplans/testit/AccountActions.csv b/data/tariffplans/testit/AccountActions.csv index 48442717c..b21040266 100644 --- a/data/tariffplans/testit/AccountActions.csv +++ b/data/tariffplans/testit/AccountActions.csv @@ -1,2 +1,3 @@ #Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled cgrates.org,1001,PACKAGE_1001,,, +cgrates.org,1002,PACKAGE_1002,,, diff --git a/data/tariffplans/testit/ActionPlans.csv b/data/tariffplans/testit/ActionPlans.csv index b8bda093e..5358216bb 100644 --- a/data/tariffplans/testit/ActionPlans.csv +++ b/data/tariffplans/testit/ActionPlans.csv @@ -1,2 +1,3 @@ #Id,ActionsId,TimingId,Weight PACKAGE_1001,TOPUP_RST_MONETARY_10,*asap,10 +PACKAGE_1002,TOPUP_RST_DATA_100,*asap,10 diff --git a/data/tariffplans/testit/Actions.csv b/data/tariffplans/testit/Actions.csv index cd5012d75..ce93a2356 100644 --- a/data/tariffplans/testit/Actions.csv +++ b/data/tariffplans/testit/Actions.csv @@ -1,3 +1,4 @@ #ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Directions[6],Categories[7],DestinationIds[8],RatingSubject[9],SharedGroup[10],ExpiryTime[11],TimingIds[12],Units[13],BalanceWeight[14],BalanceBlocker[15],BalanceDisabled[16],Weight[17] TOPUP_RST_MONETARY_10,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,10,10,false,false,10 TOPUP_MONETARY_10,*topup,,,,*monetary,*out,,*any,,,*unlimited,,10,10,false,false,10 +TOPUP_RST_DATA_100,*topup_reset,,,,*data,*out,,*any,,,*monthly,,4096,10,false,false,10 diff --git a/general_tests/accounts_it_test.go b/general_tests/accounts_it_test.go index e4807b019..7bc4c602b 100644 --- a/general_tests/accounts_it_test.go +++ b/general_tests/accounts_it_test.go @@ -23,11 +23,9 @@ import ( "net/rpc" "net/rpc/jsonrpc" "path" - //"reflect" "testing" "time" - //"github.com/cgrates/cgrates/apier/v2" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -58,6 +56,7 @@ var sTestsAcc = []func(t *testing.T){ testV1AccRemAccountSet, testV1AccGetAccountSetAfterDelete, //testV1AccRemAccountAfterDelete, + testV1AccMonthly, testV1AccStopEngine, } @@ -118,14 +117,16 @@ func testV1AccRpcConn(t *testing.T) { func testV1AccGetAccountBeforeSet(t *testing.T) { var reply *engine.Account - if err := accRpc.Call("ApierV2.GetAccount", &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { + if err := accRpc.Call("ApierV2.GetAccount", + &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}, &reply); err == nil || + err.Error() != utils.ErrNotFound.Error() { t.Error(err) } } func testV1AccLoadTarrifPlans(t *testing.T) { var reply string - attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")} + attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")} if err := accRpc.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil { t.Error(err) } else if reply != utils.OK { @@ -213,6 +214,26 @@ func testV1AccRemAccountAfterDelete(t *testing.T) { } */ +func testV1AccMonthly(t *testing.T) { + // add 10 seconds delay before and after + timeAfter := time.Now().Add(10*time.Second).AddDate(0, 1, 0) + timeBefore := time.Now().Add(-10*time.Second).AddDate(0, 1, 0) + var reply *engine.Account + if err := accRpc.Call("ApierV2.GetAccount", + &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002"}, + &reply); err != nil { + t.Error(err) + } else if _, has := reply.BalanceMap[utils.DATA]; !has { + t.Error("Unexpected balance returned: ", utils.ToJSON(reply.BalanceMap[utils.DATA])) + } else if len(reply.BalanceMap[utils.DATA]) != 1 { + t.Error("Unexpected number of balances returned: ", len(reply.BalanceMap[utils.DATA])) + } else if reply.BalanceMap[utils.DATA][0].ExpirationDate.After(timeAfter) && + reply.BalanceMap[utils.DATA][0].ExpirationDate.Before(timeBefore) { + t.Error("Unexpected expiration date returned: ", reply.BalanceMap[utils.DATA][0].ExpirationDate) + } + +} + func testV1AccStopEngine(t *testing.T) { if err := engine.KillEngine(accDelay); err != nil { t.Error(err)