Finished rates part of integration test for CDRsV1ProcessEvent

This commit is contained in:
andronache
2021-09-23 19:33:36 +03:00
committed by Dan Christian Bogos
parent 1c75005643
commit 864e460788

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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))
}
}