mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add tests for *sipcid case from ParseAttribute function
This commit is contained in:
committed by
Dan Christian Bogos
parent
86037c07ac
commit
b18467fdc3
@@ -547,11 +547,11 @@ func ParseAttribute(dp utils.DataProvider, attrType, path string, value config.R
|
||||
}
|
||||
return usedCCTime + time.Duration(debitItvl.Nanoseconds()*reqNr), nil
|
||||
case utils.MetaSIPCID:
|
||||
values := make([]string, 1, len(value))
|
||||
if len(value) < 1 {
|
||||
return nil, fmt.Errorf("invalid number of arguments <%s> to %s",
|
||||
utils.ToJSON(value), utils.MetaSIPCID)
|
||||
}
|
||||
values := make([]string, 1, len(value))
|
||||
if values[0], err = value[0].ParseDataProvider(dp); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1249,3 +1249,51 @@ func TestAttributesParseAttributeSIPCID(t *testing.T) {
|
||||
t.Errorf("Expected <%+v>, received <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttributesParseAttributeSIPCIDWrongPathErr(t *testing.T) {
|
||||
dp := utils.MapStorage{
|
||||
utils.MetaReq: utils.MapStorage{
|
||||
"cid": "12345",
|
||||
"to": "1001",
|
||||
"from": "1002",
|
||||
},
|
||||
utils.MetaOpts: 13,
|
||||
}
|
||||
value := config.NewRSRParsersMustCompile("~*req.cid;~*req.to;~*req.from;~*opts.WrongPath", utils.InfieldSep)
|
||||
if _, err := ParseAttribute(dp, utils.MetaSIPCID, utils.EmptyString, value,
|
||||
0, time.UTC.String(), utils.EmptyString, utils.InfieldSep); err == nil ||
|
||||
err.Error() != utils.ErrWrongPath.Error() {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrWrongPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttributesParseAttributeSIPCIDNotFoundErr(t *testing.T) {
|
||||
dp := utils.MapStorage{
|
||||
utils.MetaReq: utils.MapStorage{
|
||||
"to": "1001",
|
||||
"from": "1002",
|
||||
},
|
||||
}
|
||||
value := config.NewRSRParsersMustCompile("~*req.cid;~*req.to;~*req.from", utils.InfieldSep)
|
||||
if _, err := ParseAttribute(dp, utils.MetaSIPCID, utils.EmptyString, value,
|
||||
0, time.UTC.String(), utils.EmptyString, utils.InfieldSep); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttributesParseAttributeSIPCIDInvalidArguments(t *testing.T) {
|
||||
dp := utils.MapStorage{
|
||||
utils.MetaReq: utils.MapStorage{
|
||||
"to": "1001",
|
||||
"from": "1002",
|
||||
},
|
||||
}
|
||||
value := config.RSRParsers{}
|
||||
experr := `invalid number of arguments <[]> to *sipcid`
|
||||
if _, err := ParseAttribute(dp, utils.MetaSIPCID, utils.EmptyString, value,
|
||||
0, time.UTC.String(), utils.EmptyString, utils.InfieldSep); err == nil ||
|
||||
err.Error() != experr {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", experr, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1845,7 +1845,7 @@ func TestFiltersPassTimingsErrParseNotFound(t *testing.T) {
|
||||
rcv, err := fltr.passTimings(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != false {
|
||||
@@ -1972,7 +1972,7 @@ func TestFiltersPassTimingsCallSuccessful(t *testing.T) {
|
||||
rcv, err := fltr.passTimings(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != true {
|
||||
@@ -1994,7 +1994,7 @@ func TestFiltersPassTimingsCallErr(t *testing.T) {
|
||||
rcv, err := fltr.passTimings(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != false {
|
||||
@@ -2011,7 +2011,7 @@ func TestFiltersPassDestinationsErrParseNotFound(t *testing.T) {
|
||||
rcv, err := fltr.passDestinations(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != false {
|
||||
@@ -2054,7 +2054,7 @@ func TestFiltersPassDestinationsCallErr(t *testing.T) {
|
||||
rcv, err := fltr.passDestinations(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != false {
|
||||
@@ -2108,7 +2108,7 @@ func TestFiltersPassDestinationsCallSuccessSameDest(t *testing.T) {
|
||||
rcv, err := fltr.passDestinations(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != true {
|
||||
@@ -2161,7 +2161,7 @@ func TestFiltersPassDestinationsCallSuccessParseErr(t *testing.T) {
|
||||
rcv, err := fltr.passDestinations(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != false {
|
||||
@@ -2249,7 +2249,7 @@ func TestFiltersPassGreaterThanErrParseValues(t *testing.T) {
|
||||
rcv, err := fltr.passGreaterThan(dtP)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rcv != false {
|
||||
|
||||
Reference in New Issue
Block a user