From a24995ba536d200235e1832addbd2c72b6741c82 Mon Sep 17 00:00:00 2001 From: DanB Date: Wed, 14 Apr 2021 11:01:11 +0200 Subject: [PATCH] Adding a secondary account to the TestV1DebitAbstractsEventCharges --- accounts/accounts_test.go | 50 ++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/accounts/accounts_test.go b/accounts/accounts_test.go index 2943dbee2..057058aa1 100644 --- a/accounts/accounts_test.go +++ b/accounts/accounts_test.go @@ -1257,9 +1257,14 @@ func TestV1DebitAbstractsEventCharges(t *testing.T) { cb1ID := "CB1" cb2ID := "CB2" // populate the Account - acnt := &utils.Account{ + acnt1 := &utils.Account{ Tenant: utils.CGRateSorg, - ID: "TestV1DebitAbstractsEventCharges", + ID: "TestV1DebitAbstractsEventCharges1", + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, Balances: map[string]*utils.Balance{ ab1ID: &utils.Balance{ // cost: 0.4 connectFee plus 0.2 per minute, available 2 minutes, should remain 10s ID: ab1ID, @@ -1332,8 +1337,39 @@ func TestV1DebitAbstractsEventCharges(t *testing.T) { Units: utils.NewDecimal(int64(60*time.Second), 0), // 1 Minute }, cb2ID: &utils.Balance{ // absorb all costs, standard rating used when primary debitting + ID: cb2ID, + Type: utils.MetaConcrete, + Units: utils.NewDecimal(125, 2), + }, + }, + } + if err := dm.SetAccount(acnt1, true); err != nil { + t.Error(err) + } - ID: cb2ID, + acnt2 := &utils.Account{ + Tenant: utils.CGRateSorg, + ID: "TestV1DebitAbstractsEventCharges2", + Balances: map[string]*utils.Balance{ + ab1ID: &utils.Balance{ // cost: 0.4 connectFee plus 0.2 per minute, available 2 minutes, should remain 10s + ID: ab1ID, + Type: utils.MetaAbstract, + Weights: utils.DynamicWeights{ + { + Weight: 40, + }, + }, + CostIncrements: []*utils.CostIncrement{ + { + Increment: utils.NewDecimal(int64(time.Minute), 0), + FixedFee: utils.NewDecimal(4, 1), // 0.4 + RecurrentFee: utils.NewDecimal(2, 1)}, // 0.2 per minute + }, + Units: utils.NewDecimal(int64(130*time.Second), 0), // 2 Minute 10s + }, + cb1ID: &utils.Balance{ // absorb all costs, standard rating used when primary debiting + + ID: cb1ID, Type: utils.MetaConcrete, Opts: map[string]interface{}{ utils.MetaBalanceUnlimited: true, @@ -1342,7 +1378,7 @@ func TestV1DebitAbstractsEventCharges(t *testing.T) { }, }, } - if err := dm.SetAccount(acnt, true); err != nil { + if err := dm.SetAccount(acnt2, true); err != nil { t.Error(err) } @@ -1350,9 +1386,11 @@ func TestV1DebitAbstractsEventCharges(t *testing.T) { CGREvent: &utils.CGREvent{ ID: "TestV1DebitAbstractsEventCharges", Tenant: utils.CGRateSorg, + //APIOpts: map[string]interface{}{ + // utils.MetaUsage: "2m5s", + //}, Event: map[string]interface{}{ - utils.AccountField: "TestV1DebitAbstractsEventCharges", - utils.Usage: "2m5s", + utils.Usage: "2m5s", }, }, }