mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
Updated TP tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
022ad003d6
commit
4d1963ada8
@@ -25,6 +25,8 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -136,6 +138,7 @@ func testTPAlsPrfSetTPAlsPrf(t *testing.T) {
|
||||
},
|
||||
Weight: 20,
|
||||
}
|
||||
sort.Strings(tpAlsPrf.FilterIDs)
|
||||
var result string
|
||||
if err := tpAlsPrfRPC.Call("ApierV1.SetTPAttributeProfile", tpAlsPrf, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -148,8 +151,10 @@ func testTPAlsPrfGetTPAlsPrfAfterSet(t *testing.T) {
|
||||
var reply *utils.TPAttributeProfile
|
||||
if err := tpAlsPrfRPC.Call("ApierV1.GetTPAttributeProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Attr1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpAlsPrf, reply) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(reply.FilterIDs)
|
||||
if !reflect.DeepEqual(tpAlsPrf, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpAlsPrf), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
@@ -212,10 +217,19 @@ func testTPAlsPrfGetTPAlsPrfAfterUpdate(t *testing.T) {
|
||||
},
|
||||
Weight: 20,
|
||||
}
|
||||
sort.Strings(revTPAlsPrf.FilterIDs)
|
||||
sort.Slice(revTPAlsPrf.Attributes, func(i, j int) bool {
|
||||
return strings.Compare(revTPAlsPrf.Attributes[i].FieldName, revTPAlsPrf.Attributes[j].FieldName) == -1
|
||||
})
|
||||
if err := tpAlsPrfRPC.Call("ApierV1.GetTPAttributeProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Attr1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpAlsPrf, reply) && !reflect.DeepEqual(revTPAlsPrf, reply) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(reply.FilterIDs)
|
||||
sort.Slice(reply.Attributes, func(i, j int) bool {
|
||||
return strings.Compare(reply.Attributes[i].FieldName, reply.Attributes[j].FieldName) == -1
|
||||
})
|
||||
if !reflect.DeepEqual(tpAlsPrf, reply) && !reflect.DeepEqual(revTPAlsPrf, reply) {
|
||||
t.Errorf("Expecting : %+v, \n received: %+v", utils.ToJSON(tpAlsPrf), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -132,6 +133,8 @@ func testTPChrgsSetTPChrgs(t *testing.T) {
|
||||
AttributeIDs: []string{"Attr1", "Attr2"},
|
||||
Weight: 20,
|
||||
}
|
||||
sort.Strings(tpChrgs.FilterIDs)
|
||||
sort.Strings(tpChrgs.AttributeIDs)
|
||||
var result string
|
||||
if err := tpChrgsRPC.Call("ApierV1.SetTPCharger", tpChrgs, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -144,9 +147,12 @@ func testTPChrgsGetTPChrgsAfterSet(t *testing.T) {
|
||||
var reply *utils.TPChargerProfile
|
||||
if err := tpChrgsRPC.Call("ApierV1.GetTPCharger",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Chrgs"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpChrgs, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", tpChrgs, reply)
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(reply.FilterIDs)
|
||||
sort.Strings(reply.AttributeIDs)
|
||||
if !reflect.DeepEqual(tpChrgs, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpChrgs), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +163,7 @@ func testTPChrgsGetTPChrgsIDs(t *testing.T) {
|
||||
&AttrGetTPAttributeProfileIds{TPid: "TP1"}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectedTPID, result) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expectedTPID, result)
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expectedTPID), utils.ToJSON(result))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,9 +181,12 @@ func testTPChrgsGetTPChrgsAfterUpdate(t *testing.T) {
|
||||
var reply *utils.TPChargerProfile
|
||||
if err := tpChrgsRPC.Call("ApierV1.GetTPCharger",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Chrgs"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpChrgs, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", tpChrgs, reply)
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(reply.FilterIDs)
|
||||
sort.Strings(reply.AttributeIDs)
|
||||
if !reflect.DeepEqual(tpChrgs, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpChrgs), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ func testTPDispatcherRpcConn(t *testing.T) {
|
||||
|
||||
func ttestTPDispatcherGetTPDispatcherBeforeSet(t *testing.T) {
|
||||
var reply *utils.TPDispatcherProfile
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcher",
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcherProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Dsp1"},
|
||||
&reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
@@ -133,7 +133,7 @@ func testTPDispatcherSetTPDispatcher(t *testing.T) {
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := tpDispatcherRPC.Call("ApierV1.SetTPDispatcher", tpDispatcher, &result); err != nil {
|
||||
if err := tpDispatcherRPC.Call("ApierV1.SetTPDispatcherProfile", tpDispatcher, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
@@ -142,7 +142,7 @@ func testTPDispatcherSetTPDispatcher(t *testing.T) {
|
||||
|
||||
func testTPDispatcherGetTPDispatcherAfterSet(t *testing.T) {
|
||||
var reply *utils.TPDispatcherProfile
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcher",
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcherProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Dsp1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpDispatcher, reply) {
|
||||
@@ -153,7 +153,7 @@ func testTPDispatcherGetTPDispatcherAfterSet(t *testing.T) {
|
||||
func testTPDispatcherGetFilterIds(t *testing.T) {
|
||||
var result []string
|
||||
expectedTPID := []string{"Dsp1"}
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcherIDs",
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcherProfileIDs",
|
||||
&AttrGetTPDispatcherIds{TPid: "TP1"}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectedTPID, result) {
|
||||
@@ -163,7 +163,7 @@ func testTPDispatcherGetFilterIds(t *testing.T) {
|
||||
|
||||
func testTPDispatcherUpdateTPDispatcher(t *testing.T) {
|
||||
var result string
|
||||
if err := tpDispatcherRPC.Call("ApierV1.SetTPDispatcher", tpDispatcher, &result); err != nil {
|
||||
if err := tpDispatcherRPC.Call("ApierV1.SetTPDispatcherProfile", tpDispatcher, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
@@ -184,7 +184,7 @@ func testTPDispatcherGetTPDispatcherAfterUpdate(t *testing.T) {
|
||||
Strategy: utils.MetaFirst,
|
||||
Weight: 10,
|
||||
}
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcher",
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcherProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Dsp1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpDispatcher, reply) && !reflect.DeepEqual(revHosts, reply) {
|
||||
@@ -194,7 +194,7 @@ func testTPDispatcherGetTPDispatcherAfterUpdate(t *testing.T) {
|
||||
|
||||
func testTPDispatcherRemTPDispatcher(t *testing.T) {
|
||||
var resp string
|
||||
if err := tpDispatcherRPC.Call("ApierV1.RemTPDispatcher",
|
||||
if err := tpDispatcherRPC.Call("ApierV1.RemTPDispatcherProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Dsp1"}, &resp); err != nil {
|
||||
t.Error(err)
|
||||
} else if resp != utils.OK {
|
||||
@@ -204,7 +204,7 @@ func testTPDispatcherRemTPDispatcher(t *testing.T) {
|
||||
|
||||
func testTPDispatcherGetTPDispatcherAfterRemove(t *testing.T) {
|
||||
var reply *utils.TPDispatcherProfile
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcher",
|
||||
if err := tpDispatcherRPC.Call("ApierV1.GetTPDispatcherProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Dsp1"},
|
||||
&reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -142,6 +144,7 @@ func testTPFilterSetTPFilter(t *testing.T) {
|
||||
ExpiryTime: "",
|
||||
},
|
||||
}
|
||||
sort.Strings(tpFilter.Filters[0].Values)
|
||||
|
||||
var result string
|
||||
if err := tpFilterRPC.Call("ApierV1.SetTPFilterProfile", tpFilter, &result); err != nil {
|
||||
@@ -155,8 +158,10 @@ func testTPFilterGetTPFilterAfterSet(t *testing.T) {
|
||||
var reply *utils.TPFilterProfile
|
||||
if err := tpFilterRPC.Call("ApierV1.GetTPFilterProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Filter"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpFilter, reply) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(reply.Filters[0].Values)
|
||||
if !reflect.DeepEqual(tpFilter, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", tpFilter, reply)
|
||||
}
|
||||
}
|
||||
@@ -185,6 +190,11 @@ func testTPFilterUpdateTPFilter(t *testing.T) {
|
||||
Values: []string{"10", "20"},
|
||||
},
|
||||
}
|
||||
sort.Slice(tpFilter.Filters, func(i, j int) bool {
|
||||
sort.Strings(tpFilter.Filters[i].Values)
|
||||
sort.Strings(tpFilter.Filters[j].Values)
|
||||
return strings.Compare(tpFilter.Filters[i].FieldName, tpFilter.Filters[j].FieldName) == -1
|
||||
})
|
||||
var result string
|
||||
if err := tpFilterRPC.Call("ApierV1.SetTPFilterProfile", tpFilter, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -197,8 +207,14 @@ func testTPFilterGetTPFilterAfterUpdate(t *testing.T) {
|
||||
var reply *utils.TPFilterProfile
|
||||
if err := tpFilterRPC.Call("ApierV1.GetTPFilterProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Filter"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpFilter, reply) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Slice(reply.Filters, func(i, j int) bool {
|
||||
sort.Strings(reply.Filters[i].Values)
|
||||
sort.Strings(reply.Filters[j].Values)
|
||||
return strings.Compare(reply.Filters[i].FieldName, reply.Filters[j].FieldName) == -1
|
||||
})
|
||||
if !reflect.DeepEqual(tpFilter, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpFilter), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -141,6 +142,7 @@ func testTPResSetTPResource(t *testing.T) {
|
||||
Weight: 20,
|
||||
ThresholdIDs: []string{"ValOne", "ValTwo"},
|
||||
}
|
||||
sort.Strings(tpRes.ThresholdIDs)
|
||||
var result string
|
||||
if err := tpResRPC.Call("ApierV1.SetTPResource", tpRes, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -153,8 +155,10 @@ func testTPResGetTPResourceAfterSet(t *testing.T) {
|
||||
var respond *utils.TPResourceProfile
|
||||
if err := tpResRPC.Call("ApierV1.GetTPResource", &utils.TPTntID{TPid: "TPR1", Tenant: "cgrates.org", ID: "ResGroup1"},
|
||||
&respond); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpRes, respond) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(respond.ThresholdIDs)
|
||||
if !reflect.DeepEqual(tpRes, respond) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", tpRes, respond)
|
||||
}
|
||||
}
|
||||
@@ -162,6 +166,7 @@ func testTPResGetTPResourceAfterSet(t *testing.T) {
|
||||
func testTPResUpdateTPResource(t *testing.T) {
|
||||
var result string
|
||||
tpRes.FilterIDs = []string{"FLTR_1", "FLTR_STS1"}
|
||||
sort.Strings(tpRes.FilterIDs)
|
||||
if err := tpResRPC.Call("ApierV1.SetTPResource", tpRes, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
@@ -173,8 +178,11 @@ func testTPResGetTPResourceAfterUpdate(t *testing.T) {
|
||||
var expectedTPR *utils.TPResourceProfile
|
||||
if err := tpResRPC.Call("ApierV1.GetTPResource", &utils.TPTntID{TPid: "TPR1", Tenant: "cgrates.org", ID: "ResGroup1"},
|
||||
&expectedTPR); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpRes, expectedTPR) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(expectedTPR.FilterIDs)
|
||||
sort.Strings(expectedTPR.ThresholdIDs)
|
||||
if !reflect.DeepEqual(tpRes, expectedTPR) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tpRes, expectedTPR)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -145,6 +147,7 @@ func testTPStatsSetTPStat(t *testing.T) {
|
||||
MinItems: 1,
|
||||
ThresholdIDs: []string{"ThreshValue", "ThreshValueTwo"},
|
||||
}
|
||||
sort.Strings(tpStat.ThresholdIDs)
|
||||
var result string
|
||||
if err := tpStatRPC.Call("ApierV1.SetTPStat", tpStat, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -157,8 +160,10 @@ func testTPStatsGetTPStatAfterSet(t *testing.T) {
|
||||
var respond *utils.TPStatProfile
|
||||
if err := tpStatRPC.Call("ApierV1.GetTPStat",
|
||||
&utils.TPTntID{TPid: "TPS1", Tenant: "cgrates.org", ID: "Stat1"}, &respond); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpStat, respond) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(respond.ThresholdIDs)
|
||||
if !reflect.DeepEqual(tpStat, respond) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tpStat, respond)
|
||||
}
|
||||
}
|
||||
@@ -174,6 +179,9 @@ func testTPStatsUpdateTPStat(t *testing.T) {
|
||||
MetricID: "*averege",
|
||||
},
|
||||
}
|
||||
sort.Slice(tpStat.Metrics, func(i, j int) bool {
|
||||
return strings.Compare(tpStat.Metrics[i].MetricID, tpStat.Metrics[j].MetricID) == -1
|
||||
})
|
||||
if err := tpStatRPC.Call("ApierV1.SetTPStat", tpStat, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
@@ -185,8 +193,13 @@ func testTPStatsGetTPStatAfterUpdate(t *testing.T) {
|
||||
var expectedTPS *utils.TPStatProfile
|
||||
if err := tpStatRPC.Call("ApierV1.GetTPStat",
|
||||
&utils.TPTntID{TPid: "TPS1", Tenant: "cgrates.org", ID: "Stat1"}, &expectedTPS); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpStat, expectedTPS) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(expectedTPS.ThresholdIDs)
|
||||
sort.Slice(expectedTPS.Metrics, func(i, j int) bool {
|
||||
return strings.Compare(expectedTPS.Metrics[i].MetricID, expectedTPS.Metrics[j].MetricID) == -1
|
||||
})
|
||||
if !reflect.DeepEqual(tpStat, expectedTPS) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tpStat, expectedTPS)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -145,6 +147,7 @@ func testTPSplPrfSetTPSplPrf(t *testing.T) {
|
||||
},
|
||||
Weight: 20,
|
||||
}
|
||||
sort.Strings(tpSplPr.FilterIDs)
|
||||
var result string
|
||||
if err := tpSplPrfRPC.Call("ApierV1.SetTPSupplierProfile",
|
||||
tpSplPr, &result); err != nil {
|
||||
@@ -158,8 +161,10 @@ func testTPSplPrfGetTPSplPrfAfterSet(t *testing.T) {
|
||||
var reply *utils.TPSupplierProfile
|
||||
if err := tpSplPrfRPC.Call("ApierV1.GetTPSupplierProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "SUPL_1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpSplPr, reply) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(reply.FilterIDs)
|
||||
if !reflect.DeepEqual(tpSplPr, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpSplPr), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
@@ -208,39 +213,22 @@ func testTPSplPrfUpdateTPSplPrf(t *testing.T) {
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
sort.Slice(tpSplPr.Suppliers, func(i, j int) bool {
|
||||
return strings.Compare(tpSplPr.Suppliers[i].ID, tpSplPr.Suppliers[j].ID) == -1
|
||||
})
|
||||
}
|
||||
|
||||
func testTPSplPrfGetTPSplPrfAfterUpdate(t *testing.T) {
|
||||
var reply *utils.TPSupplierProfile
|
||||
reverseSuppliers := []*utils.TPSupplier{
|
||||
&utils.TPSupplier{
|
||||
ID: "supplier2",
|
||||
FilterIDs: []string{"FLTR_1"},
|
||||
AccountIDs: []string{"Acc3"},
|
||||
RatingPlanIDs: []string{"RPL_1"},
|
||||
ResourceIDs: []string{"ResGroup1"},
|
||||
StatIDs: []string{"Stat1"},
|
||||
Weight: 20,
|
||||
Blocker: false,
|
||||
SupplierParameters: "SortingParam2",
|
||||
},
|
||||
&utils.TPSupplier{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{"FLTR_1"},
|
||||
AccountIDs: []string{"Acc1", "Acc2"},
|
||||
RatingPlanIDs: []string{"RPL_1"},
|
||||
ResourceIDs: []string{"ResGroup1"},
|
||||
StatIDs: []string{"Stat1"},
|
||||
Weight: 10,
|
||||
Blocker: true,
|
||||
SupplierParameters: "SortingParam1",
|
||||
},
|
||||
}
|
||||
if err := tpSplPrfRPC.Call("ApierV1.GetTPSupplierProfile",
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "SUPL_1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpSplPr.Suppliers, reply.Suppliers) &&
|
||||
!reflect.DeepEqual(tpSplPr.Suppliers, reverseSuppliers) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(reply.FilterIDs)
|
||||
sort.Slice(reply.Suppliers, func(i, j int) bool {
|
||||
return strings.Compare(reply.Suppliers[i].ID, reply.Suppliers[j].ID) == -1
|
||||
})
|
||||
if !reflect.DeepEqual(tpSplPr.Suppliers, reply.Suppliers) {
|
||||
t.Errorf("Expecting: %+v,\n received: %+v", utils.ToJSON(tpSplPr), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -141,6 +142,8 @@ func testTPThreholdSetTPThrehold(t *testing.T) {
|
||||
ActionIDs: []string{"Thresh1", "Thresh2"},
|
||||
Async: true,
|
||||
}
|
||||
sort.Strings(tpThreshold.FilterIDs)
|
||||
sort.Strings(tpThreshold.ActionIDs)
|
||||
var result string
|
||||
if err := tpThresholdRPC.Call("ApierV1.SetTPThreshold", tpThreshold, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -153,8 +156,11 @@ func testTPThreholdGetTPThreholdAfterSet(t *testing.T) {
|
||||
var respond *utils.TPThresholdProfile
|
||||
if err := tpThresholdRPC.Call("ApierV1.GetTPThreshold",
|
||||
&utils.TPTntID{TPid: "TH1", Tenant: "cgrates.org", ID: "Threshold"}, &respond); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpThreshold, respond) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(respond.FilterIDs)
|
||||
sort.Strings(respond.ActionIDs)
|
||||
if !reflect.DeepEqual(tpThreshold, respond) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tpThreshold, respond)
|
||||
}
|
||||
}
|
||||
@@ -164,7 +170,7 @@ func testTPThreholdGetTPThreholdIds(t *testing.T) {
|
||||
expectedTPID := []string{"Threshold"}
|
||||
if err := tpThresholdRPC.Call("ApierV1.GetTPThresholdIDs",
|
||||
&AttrGetTPThresholdIds{TPid: tpThreshold.TPid}, &result); err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, expectedTPID) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", result, expectedTPID)
|
||||
}
|
||||
@@ -184,8 +190,11 @@ func testTPThreholdGetTPThreholdAfterUpdate(t *testing.T) {
|
||||
var respond *utils.TPThresholdProfile
|
||||
if err := tpThresholdRPC.Call("ApierV1.GetTPThreshold",
|
||||
&utils.TPTntID{TPid: "TH1", Tenant: "cgrates.org", ID: "Threshold"}, &respond); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpThreshold, respond) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sort.Strings(respond.FilterIDs)
|
||||
sort.Strings(respond.ActionIDs)
|
||||
if !reflect.DeepEqual(tpThreshold, respond) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tpThreshold, respond)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user