From 8b224e85c03137028881eaa90fe9dc803ac0ef1e Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 24 Jun 2020 15:04:43 +0300 Subject: [PATCH] Add test for getting other fields from CostDetails --- engine/cdr_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/engine/cdr_test.go b/engine/cdr_test.go index 1912db1c2..9bb0b46c0 100644 --- a/engine/cdr_test.go +++ b/engine/cdr_test.go @@ -813,6 +813,34 @@ func TestCDRAsExportRecord(t *testing.T) { t.Errorf("Expecting: <%q>,\n Received: <%q>", expected, expRecord[0]) } + expected = "CustomDestination" + prsr = config.NewRSRParsersMustCompile("~*req.CostDetails.RatingFilters:s/DestinationID\"\\s?\\:\\s?\"([^\"]*)\".*/$1/", true, utils.INFIELD_SEP) + cfgCdrFld = &config.FCTemplate{ + Tag: "DestinationID", + Type: utils.META_COMPOSED, + Path: "*exp.CustomDestinationID", + Value: prsr, + } + if expRecord, err := cdr.AsExportRecord([]*config.FCTemplate{cfgCdrFld}, false, nil, nil); err != nil { + t.Error(err) + } else if expRecord[0] != expected { + t.Errorf("Expecting: <%q>,\n Received: <%q>", expected, expRecord[0]) + } + + expected = "26377" + prsr = config.NewRSRParsersMustCompile("~*req.CostDetails.RatingFilters:s/DestinationPrefix\"\\s?\\:\\s?\"([^\"]*)\".*/$1/", true, utils.INFIELD_SEP) + cfgCdrFld = &config.FCTemplate{ + Tag: "DestinationID", + Type: utils.META_COMPOSED, + Path: "*exp.CustomDestinationID", + Value: prsr, + } + if expRecord, err := cdr.AsExportRecord([]*config.FCTemplate{cfgCdrFld}, false, nil, nil); err != nil { + t.Error(err) + } else if expRecord[0] != expected { + t.Errorf("Expecting: <%q>,\n Received: <%q>", expected, expRecord[0]) + } + } func TestCDRAsExportMap(t *testing.T) {