Remove Paginator from GetSuppliers

This commit is contained in:
TeoV
2019-04-15 17:35:53 +03:00
parent 45c843a3a4
commit 365032c4d9
3 changed files with 0 additions and 98 deletions

View File

@@ -416,16 +416,6 @@ func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sor
if err != nil {
return nil, err
}
if args.Paginator.Offset != nil {
if *args.Paginator.Offset <= len(sortedSuppliers.SortedSuppliers) {
sortedSuppliers.SortedSuppliers = sortedSuppliers.SortedSuppliers[*args.Paginator.Offset:]
}
}
if args.Paginator.Limit != nil {
if *args.Paginator.Limit <= len(sortedSuppliers.SortedSuppliers) {
sortedSuppliers.SortedSuppliers = sortedSuppliers.SortedSuppliers[:*args.Paginator.Limit]
}
}
return sortedSuppliers, nil
}
@@ -433,7 +423,6 @@ type ArgsGetSuppliers struct {
IgnoreErrors bool
MaxCost string // toDo: try with interface{} here
utils.CGREvent
utils.Paginator
*utils.ArgDispatcher
}

View File

@@ -492,92 +492,6 @@ func TestSuppliersSortedForEvent(t *testing.T) {
}
}
func TestSuppliersSortedForEventWithLimit(t *testing.T) {
eFirstSupplierProfile := &SortedSuppliers{
ProfileID: "SupplierProfile2",
Sorting: utils.MetaWeight,
SortedSuppliers: []*SortedSupplier{
{
SupplierID: "supplier1",
SortingData: map[string]interface{}{
"Weight": 30.0,
},
SupplierParameters: "param1",
},
{
SupplierID: "supplier2",
SortingData: map[string]interface{}{
"Weight": 20.0,
},
SupplierParameters: "param2",
},
},
}
argsGetSuppliers[1].Paginator = utils.Paginator{
Limit: utils.IntPointer(2),
}
sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1])
if err != nil {
t.Errorf("Error: %+v", err)
}
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf)
}
}
func TestSuppliersSortedForEventWithOffset(t *testing.T) {
eFirstSupplierProfile := &SortedSuppliers{
ProfileID: "SupplierProfile2",
Sorting: utils.MetaWeight,
SortedSuppliers: []*SortedSupplier{
{
SupplierID: "supplier3",
SortingData: map[string]interface{}{
"Weight": 10.0,
},
SupplierParameters: "param3",
},
},
}
argsGetSuppliers[1].Paginator = utils.Paginator{
Offset: utils.IntPointer(2),
}
sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1])
if err != nil {
t.Errorf("Error: %+v", err)
}
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf))
}
}
func TestSuppliersSortedForEventWithLimitAndOffset(t *testing.T) {
eFirstSupplierProfile := &SortedSuppliers{
ProfileID: "SupplierProfile2",
Sorting: utils.MetaWeight,
SortedSuppliers: []*SortedSupplier{
{
SupplierID: "supplier2",
SortingData: map[string]interface{}{
"Weight": 20.0,
},
SupplierParameters: "param2",
},
},
}
argsGetSuppliers[1].Paginator = utils.Paginator{
Limit: utils.IntPointer(1),
Offset: utils.IntPointer(1),
}
sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1])
if err != nil {
t.Errorf("Error: %+v", err)
}
if !reflect.DeepEqual(eFirstSupplierProfile, sprf) {
t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf))
}
}
func TestSuppliersAsOptsGetSuppliers(t *testing.T) {
s := &ArgsGetSuppliers{
IgnoreErrors: true,

View File

@@ -1720,7 +1720,6 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection,
IgnoreErrors: args.SuppliersIgnoreErrors,
MaxCost: args.SuppliersMaxCost,
CGREvent: *cgrEv,
Paginator: args.Paginator,
ArgDispatcher: args.ArgDispatcher,
}
if err = sS.splS.Call(utils.SupplierSv1GetSuppliers,