mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add a model test(to be modify) for QOS
This commit is contained in:
committed by
Dan Christian Bogos
parent
0f55c6e076
commit
defdc220e0
@@ -26,7 +26,6 @@ import (
|
||||
|
||||
func TestLibSuppliersSortCost(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
Sorting: utils.MetaLeastCost,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
@@ -56,7 +55,6 @@ func TestLibSuppliersSortCost(t *testing.T) {
|
||||
}
|
||||
sSpls.SortLeastCost()
|
||||
eOrderedSpls := &SortedSuppliers{
|
||||
Sorting: utils.MetaLeastCost,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
@@ -223,7 +221,6 @@ func TestSortedSuppliersDigest3(t *testing.T) {
|
||||
|
||||
func TestLibSuppliersSortHighestCost(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
Sorting: utils.MetaHighestCost,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
@@ -253,7 +250,6 @@ func TestLibSuppliersSortHighestCost(t *testing.T) {
|
||||
}
|
||||
sSpls.SortHighestCost()
|
||||
eOrderedSpls := &SortedSuppliers{
|
||||
Sorting: utils.MetaHighestCost,
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
@@ -286,3 +282,68 @@ func TestLibSuppliersSortHighestCost(t *testing.T) {
|
||||
utils.ToJSON(eOrderedSpls), utils.ToJSON(sSpls))
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibSuppliersSortQOS(t *testing.T) {
|
||||
sSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.1,
|
||||
utils.MetaTCD: 15.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.2,
|
||||
utils.MetaTCD: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.05,
|
||||
utils.MetaTCD: 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
},
|
||||
},
|
||||
}
|
||||
sSpls.SortQOS()
|
||||
eOrderedSpls := &SortedSuppliers{
|
||||
SortedSuppliers: []*SortedSupplier{
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.05,
|
||||
utils.MetaTCD: 10.0,
|
||||
},
|
||||
SupplierParameters: "param3",
|
||||
},
|
||||
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.2,
|
||||
utils.MetaTCD: 20.0,
|
||||
},
|
||||
SupplierParameters: "param2",
|
||||
},
|
||||
&SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 0.1,
|
||||
utils.MetaTCD: 15.0,
|
||||
},
|
||||
SupplierParameters: "param1",
|
||||
},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(eOrderedSpls, sSpls) {
|
||||
t.Errorf("Expecting: %s, received: %s",
|
||||
utils.ToJSON(eOrderedSpls), utils.ToJSON(sSpls))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,11 @@ func (lcs *HightCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
|
||||
for k, v := range costData {
|
||||
srtData[k] = v
|
||||
}
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, &SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers,
|
||||
&SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
}
|
||||
if len(sortedSuppls.SortedSuppliers) == 0 {
|
||||
return nil, utils.ErrNotFound
|
||||
|
||||
@@ -66,10 +66,11 @@ func (lcs *LeastCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
|
||||
for k, v := range costData {
|
||||
srtData[k] = v
|
||||
}
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, &SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers,
|
||||
&SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
}
|
||||
if len(sortedSuppls.SortedSuppliers) == 0 {
|
||||
return nil, utils.ErrNotFound
|
||||
|
||||
@@ -60,10 +60,11 @@ func (lcs *QOSSupplierSorter) SortSuppliers(prflID string, suppls []*Supplier,
|
||||
srtData[k] = v
|
||||
}
|
||||
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, &SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers,
|
||||
&SortedSupplier{
|
||||
SupplierID: s.ID,
|
||||
SortingData: srtData,
|
||||
SupplierParameters: s.SupplierParameters})
|
||||
}
|
||||
if len(sortedSuppls.SortedSuppliers) == 0 {
|
||||
return nil, utils.ErrNotFound
|
||||
|
||||
Reference in New Issue
Block a user