Adding test for parsing MatchedDestinationId

This commit is contained in:
DanB
2016-11-30 13:26:30 +01:00
parent a9e4a35601
commit cd73bf7631

View File

@@ -231,6 +231,15 @@ func TestRSRCostDetails(t *testing.T) {
if parsedVal := rsrField.ParseValue(fieldsStr1); parsedVal != "Canada" {
t.Errorf("Expecting: Canada, received: %s", parsedVal)
}
fieldsStr2 := `{"Direction":"*out","Category":"call","Tenant":"sip.test.cgrates.org","Subject":"dan","Account":"dan","Destination":"+4986517174963","TOR":"*voice","Cost":0,"Timespans":[{"TimeStart":"2015-05-13T15:03:34+02:00","TimeEnd":"2015-05-13T15:03:38+02:00","Cost":0,"RateInterval":{"Timing":{"Years":[],"Months":[],"MonthDays":[],"WeekDays":[],"StartTime":"00:00:00","EndTime":""},"Rating":{"ConnectFee":0,"RoundingMethod":"*middle","RoundingDecimals":4,"MaxCost":0,"MaxCostStrategy":"","Rates":[{"GroupIntervalStart":0,"Value":0,"RateIncrement":1000000000,"RateUnit":60000000000}]},"Weight":10},"DurationIndex":4000000000,"Increments":[{"Duration":1000000000,"Cost":0,"BalanceInfo":{"Unit":null,"Monetary":null,"AccountID":""},"CompressFactor":4}],"RoundIncrement":null,"MatchedSubject":"*out:sip.test.cgrates.org:call:*any","MatchedPrefix":"+31800","MatchedDestId":"CST_49800_DE080","RatingPlanId":"ISC_V","CompressFactor":1}],"RatedUsage":4}`
rsrField, err = NewRSRField(`~CostDetails:s/"MatchedDestId":.*_(\w{5})_/${1}/:s/"MatchedDestId":"INTERNAL"/ON010/`)
if err != nil {
t.Error(err)
}
eMatch := "49800"
if parsedVal := rsrField.ParseValue(fieldsStr2); parsedVal != eMatch {
t.Errorf("Expecting: <%s>, received: <%s>", eMatch, parsedVal)
}
}
func TestRSRFilterPass(t *testing.T) {