From 864e460788b9ca79d944f1c9d6c2c0f893db0800 Mon Sep 17 00:00:00 2001 From: andronache Date: Thu, 23 Sep 2021 19:33:36 +0300 Subject: [PATCH] Finished rates part of integration test for CDRsV1ProcessEvent --- general_tests/ld_process_match_rt_it_test.go | 80 ++++++++++++++------ 1 file changed, 58 insertions(+), 22 deletions(-) diff --git a/general_tests/ld_process_match_rt_it_test.go b/general_tests/ld_process_match_rt_it_test.go index e6a37c80c..be47d7917 100644 --- a/general_tests/ld_process_match_rt_it_test.go +++ b/general_tests/ld_process_match_rt_it_test.go @@ -15,7 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see */ -package general_tests +package apis import ( "net" @@ -43,11 +43,11 @@ var ( testLdPrMatchRtLoadConfig, testLdPrMatchRtResetDataDB, testLdPrMatchRtResetStorDb, - // testLdPrMatchRtStartEngine, + testLdPrMatchRtStartEngine, testLdPrMatchRtRPCConn, testLdPrMatchRtLoadTP, testLdPrMatchRtCDRSProcessEvent, - // testLdPrMatchRtStopCgrEngine, + testLdPrMatchRtStopCgrEngine, } ) @@ -170,25 +170,61 @@ func testLdPrMatchRtCDRSProcessEvent(t *testing.T) { if !reflect.DeepEqual(utils.ToJSON(&expected), utils.ToJSON(&rply)) { t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(&expected), utils.ToJSON(&rply)) } - // costInterval := testRPC1.Event.Event["*rateSCost"].(map[string]interface{})["CostIntervals"] - // ratesField := testRPC1.Event.Event["*rateSCost"].(map[string]interface{})["Rates"] - // expected2 := utils.CGREvent{ - // Tenant: "cgrates.org", - // ID: "TestEv1", - // Event: map[string]interface{}{ - // "Altered": nil, - // utils.Cost: 0.4, - // "CostIntervals": costInterval, - // "ID": "RT_RETAIL1", - // "MaxCost": 0, - // "MaxCostStrategy": "", - // "MinCost": 0, - // "Rates": ratesField, - // }, - // } - // if !reflect.DeepEqual(utils.ToJSON(expected2), utils.ToJSON(testRPC1.Event)) { - // t.Errorf("\nExpecting : %+v \n,received: %+v", utils.ToJSON(expected2), utils.ToJSON(testRPC1.Event)) - // } + costIntervalRatesID := testRPC1.Event.Event["*rateSCost"].(map[string]interface{})["CostIntervals"].([]interface{})[0].(map[string]interface{})["Increments"].([]interface{})[0].(map[string]interface{})["RateID"] + expected2 := &utils.CGREventWithEeIDs{ + EeIDs: nil, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestEv1", + Event: map[string]interface{}{ + "*rateSCost": map[string]interface{}{ + "Altered": nil, + utils.Cost: 0.4, + "CostIntervals": []map[string]interface{}{ + { + "CompressFactor": 1, + "Increments": []map[string]interface{}{ + { + "CompressFactor": 2, + "RateID": costIntervalRatesID, + "RateIntervalIndex": 0, + "Usage": 60000000000, + }, + }, + }, + }, + "ID": "RT_RETAIL1", + "MaxCost": 0, + "MaxCostStrategy": "", + "MinCost": 0, + "Rates": map[string]interface{}{ + utils.IfaceAsString(costIntervalRatesID): map[string]interface{}{ + "FixedFee": 0, + "Increment": 30000000000, + "IntervalStart": 0, + "RecurrentFee": 0.4, + "Unit": 60000000000, + }, + }, + }, + "Account": "1001", + "Destination": "1002", + "OriginID": "TestEv1", + "RequestType": "*prepaid", + "Subject": "1001", + "ToR": "*voice", + "Usage": 60000000000, + }, + APIOpts: map[string]interface{}{ + utils.OptsRateS: true, + utils.OptsCDRsExport: true, + utils.OptsAccountS: false, + }, + }, + } + if !reflect.DeepEqual(utils.ToJSON(expected2), utils.ToJSON(testRPC1.Event)) { + t.Errorf("\nExpecting : %+v \n,received: %+v", utils.ToJSON(expected2), utils.ToJSON(testRPC1.Event)) + } }