mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fixed DispatcherService SessionSv1 tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
0a9e5f7bdd
commit
1f2fcfd4b9
@@ -34,6 +34,8 @@ import (
|
||||
)
|
||||
|
||||
var sTestsDspSession = []func(t *testing.T){
|
||||
testDspSessionAddBalacne,
|
||||
|
||||
testDspSessionPingFailover,
|
||||
|
||||
testDspSessionPing,
|
||||
@@ -67,6 +69,36 @@ func TestDspSessionS(t *testing.T) {
|
||||
engine.KillEngine(0)
|
||||
}
|
||||
|
||||
func testDspSessionAddBalacne(t *testing.T) {
|
||||
initUsage := 15 * time.Minute
|
||||
attrSetBalance := utils.AttrSetBalance{
|
||||
Tenant: "cgrates.org",
|
||||
Account: "1001",
|
||||
BalanceType: utils.VOICE,
|
||||
BalanceID: utils.StringPointer("SessionBalance"),
|
||||
Value: utils.Float64Pointer(float64(initUsage)),
|
||||
RatingSubject: utils.StringPointer("*zero5ms"),
|
||||
}
|
||||
var reply string
|
||||
if err := allEngine.RCP.Call("ApierV2.SetBalance", attrSetBalance, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{
|
||||
Tenant: attrSetBalance.Tenant,
|
||||
Account: attrSetBalance.Account,
|
||||
}
|
||||
eAcntVal := float64(initUsage)
|
||||
if err := allEngine.RCP.Call("ApierV2.GetAccount", attrs, &acnt); err != nil {
|
||||
t.Error(err)
|
||||
} else if acnt.BalanceMap[utils.VOICE].GetTotalValue() != eAcntVal {
|
||||
t.Errorf("Expecting: %v, received: %v",
|
||||
time.Duration(eAcntVal), time.Duration(acnt.BalanceMap[utils.VOICE].GetTotalValue()))
|
||||
}
|
||||
}
|
||||
|
||||
func testDspSessionPing(t *testing.T) {
|
||||
var reply string
|
||||
if err := allEngine.RCP.Call(utils.SessionSv1Ping, &utils.CGREvent{}, &reply); err != nil {
|
||||
@@ -386,20 +418,6 @@ func testDspSessionProcessCDR(t *testing.T) {
|
||||
|
||||
func testDspSessionProcessEvent(t *testing.T) {
|
||||
initUsage := 5 * time.Minute
|
||||
attrSetBalance := utils.AttrSetBalance{
|
||||
Tenant: "cgrates.org",
|
||||
Account: "1001",
|
||||
BalanceType: utils.VOICE,
|
||||
BalanceID: utils.StringPointer("TestDynamicDebitBalance"),
|
||||
Value: utils.Float64Pointer(float64(initUsage)),
|
||||
RatingSubject: utils.StringPointer("*zero5ms"),
|
||||
}
|
||||
var reply string
|
||||
if err := allEngine.RCP.Call("ApierV2.SetBalance", attrSetBalance, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
args := ProcessEventWithApiKey{
|
||||
DispatcherResource: DispatcherResource{
|
||||
APIKey: "ses12345",
|
||||
|
||||
Reference in New Issue
Block a user