mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
fixed failing integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
3c45d8ba18
commit
8f0a3b50b8
@@ -279,8 +279,8 @@ func testV1STSSetStatQueueProfile(t *testing.T) {
|
||||
ID: "TEST_PROFILE1",
|
||||
FilterIDs: []string{"FLTR_1"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local(),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local(),
|
||||
},
|
||||
QueueLength: 10,
|
||||
TTL: time.Duration(10) * time.Second,
|
||||
|
||||
@@ -156,7 +156,7 @@ func testV1SplSGetWeightSuppliers(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1SplSGetLeastCostSuppliers(t *testing.T) {
|
||||
ev := &engine.SupplierEvent{
|
||||
ev := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetLeastCostSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
@@ -174,22 +174,25 @@ func testV1SplSGetLeastCostSuppliers(t *testing.T) {
|
||||
&engine.SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.02,
|
||||
utils.Weight: 15.0,
|
||||
utils.Cost: 0.02,
|
||||
utils.RatingPlanID: "RP_SPECIAL_1002",
|
||||
utils.Weight: 15.0,
|
||||
},
|
||||
},
|
||||
&engine.SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.02,
|
||||
utils.Weight: 10.0,
|
||||
utils.Cost: 0.02,
|
||||
utils.RatingPlanID: "RP_SPECIAL_1002",
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
},
|
||||
&engine.SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 0.46666,
|
||||
utils.Weight: 20.0,
|
||||
utils.Cost: 0.46666,
|
||||
utils.RatingPlanID: "RP_RETAIL1",
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -356,8 +356,8 @@ func testV1TSSetThresholdProfile(t *testing.T) {
|
||||
ID: "TEST_PROFILE1",
|
||||
FilterIDs: []string{"FilterID1", "FilterID2"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
},
|
||||
Recurrent: true,
|
||||
MinSleep: time.Duration(5 * time.Minute),
|
||||
|
||||
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -115,4 +117,48 @@ func TestCGREventFieldAsString(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
//float , float in string time duration
|
||||
func TestCGREventFieldAsFloat64(t *testing.T) {
|
||||
err1 := fmt.Errorf("cannot cast %s to string", ANSWER_TIME)
|
||||
event := make(map[string]interface{})
|
||||
event[ANSWER_TIME] = time.Now().Local()
|
||||
event["supplierprofile1"] = "Supplier"
|
||||
event["UsageInterval"] = "54.2"
|
||||
event["PddInterval"] = "1s"
|
||||
event["Weight"] = 20.0
|
||||
se := &CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "supplierevent1",
|
||||
Event: event,
|
||||
}
|
||||
answ, err := se.FieldAsFloat64("UsageInterval")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if answ != float64(54.2) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", event["UsageInterval"], answ)
|
||||
}
|
||||
answ, err = se.FieldAsFloat64("Weight")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if answ != float64(20.0) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", event["Weight"], answ)
|
||||
}
|
||||
answ, err = se.FieldAsFloat64("PddInterval")
|
||||
//TODO: Make an error to be expected :
|
||||
// cgrevent_test.go:149: strconv.ParseFloat: parsing "1s": invalid syntax
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
if answ != 0 {
|
||||
t.Errorf("Expecting: %+v, received: %+v", 0, answ)
|
||||
}
|
||||
|
||||
answ, err = se.FieldAsFloat64(ANSWER_TIME)
|
||||
if !reflect.DeepEqual(err, err1) {
|
||||
t.Error(err)
|
||||
}
|
||||
if answ != 0 {
|
||||
t.Errorf("Expecting: %+v, received: %+v", 0, answ)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user