mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add test for Attributes and Supplier ( Digest() method )
This commit is contained in:
committed by
Dan Christian Bogos
parent
9d22f680f4
commit
df405ff3e6
@@ -119,5 +119,70 @@ func TestNewExternalAttributeProfileFromAttributeProfile(t *testing.T) {
|
||||
if !reflect.DeepEqual(expected, rcv) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestAttrSProcessEventReplyDigest(t *testing.T) {
|
||||
eRpl := &AttrSProcessEventReply{
|
||||
MatchedProfile: "ATTR_1",
|
||||
AlteredFields: []string{"Account", "Subject"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaRating),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1001",
|
||||
"Subject": "1001",
|
||||
"Destination": "+491511231234",
|
||||
},
|
||||
},
|
||||
}
|
||||
expRpl := "Account:1001,Subject:1001"
|
||||
val := eRpl.Digest()
|
||||
if !reflect.DeepEqual(val, expRpl) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expRpl), utils.ToJSON(val))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttrSProcessEventReplyDigest2(t *testing.T) {
|
||||
eRpl := &AttrSProcessEventReply{
|
||||
MatchedProfile: "ATTR_1",
|
||||
AlteredFields: []string{},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaRating),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1001",
|
||||
"Subject": "1001",
|
||||
"Destination": "+491511231234",
|
||||
},
|
||||
},
|
||||
}
|
||||
expRpl := ""
|
||||
val := eRpl.Digest()
|
||||
if !reflect.DeepEqual(val, expRpl) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expRpl), utils.ToJSON(val))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttrSProcessEventReplyDigest3(t *testing.T) {
|
||||
eRpl := &AttrSProcessEventReply{
|
||||
MatchedProfile: "ATTR_1",
|
||||
AlteredFields: []string{"Subject"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaRating),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1001",
|
||||
"Subject": "1001",
|
||||
"Destination": "+491511231234",
|
||||
},
|
||||
},
|
||||
}
|
||||
expRpl := "Subject:1001"
|
||||
val := eRpl.Digest()
|
||||
if !reflect.DeepEqual(val, expRpl) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expRpl), utils.ToJSON(val))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,3 +149,72 @@ func TestLibSuppliersSortWeight(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eSpls.Sorting, result.Sorting)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortedSuppliersDigest(t *testing.T) {
|
||||
eSpls := SortedSuppliers{
|
||||
ProfileID: "SPL_WEIGHT_1",
|
||||
Sorting: utils.MetaWeight,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 10.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
},
|
||||
},
|
||||
}
|
||||
exp := "supplier2:param2,supplier1:param1"
|
||||
rcv := eSpls.Digest()
|
||||
if !reflect.DeepEqual(rcv, exp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", exp, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortedSuppliersDigest2(t *testing.T) {
|
||||
eSpls := SortedSuppliers{
|
||||
ProfileID: "SPL_WEIGHT_1",
|
||||
Sorting: utils.MetaWeight,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 30.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Weight": 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
},
|
||||
},
|
||||
}
|
||||
exp := "supplier1:param1,supplier2:param2"
|
||||
rcv := eSpls.Digest()
|
||||
if !reflect.DeepEqual(rcv, exp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", exp, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortedSuppliersDigest3(t *testing.T) {
|
||||
eSpls := SortedSuppliers{
|
||||
ProfileID: "SPL_WEIGHT_1",
|
||||
Sorting: utils.MetaWeight,
|
||||
SortedSuppliers: []*SortedSupplier{},
|
||||
}
|
||||
exp := ""
|
||||
rcv := eSpls.Digest()
|
||||
if !reflect.DeepEqual(rcv, exp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", exp, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user