mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
Refactoring Tests
This commit is contained in:
@@ -60,14 +60,10 @@ var sTestsOnStorIT = []func(t *testing.T){
|
||||
testOnStorITCacheResourceLimit,
|
||||
// ToDo: test cache flush for a prefix
|
||||
testOnStorITHasData,
|
||||
testOnStorITGetRatingPlan,
|
||||
testOnStorITSetRatingPlan,
|
||||
testOnStorITGetRatingProfile,
|
||||
testOnStorITRemoveRatingProfile,
|
||||
testOnStorITGetDestination,
|
||||
testOnStorITSetDestination,
|
||||
testOnStorITRemoveDestination,
|
||||
testOnStorITGetReverseDestination,
|
||||
testOnStorITCRUDRatingPlan,
|
||||
testOnStorITCRUDRatingProfile,
|
||||
testOnStorITCRUDDestination,
|
||||
// ToFix: testOnStorITCRUDReverseDestination,
|
||||
}
|
||||
|
||||
func TestOnStorITRedisConnect(t *testing.T) {
|
||||
@@ -768,9 +764,9 @@ func testOnStorITHasData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITGetRatingPlan(t *testing.T) {
|
||||
func testOnStorITCRUDRatingPlan(t *testing.T) {
|
||||
rp := &RatingPlan{
|
||||
Id: "GetRatingPlan",
|
||||
Id: "CRUDRatingPlan",
|
||||
Timings: map[string]*RITiming{
|
||||
"59a981b9": &RITiming{
|
||||
Years: utils.Years{},
|
||||
@@ -805,7 +801,7 @@ func testOnStorITGetRatingPlan(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, rcvErr := onStor.GetRatingPlan(rp.Id, true, utils.NonTransactional); rcvErr != utils.ErrNotFound {
|
||||
if _, rcvErr := onStor.GetRatingPlan(rp.Id, true, utils.NonTransactional); rcvErr == err {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
if err := onStor.SetRatingPlan(rp, utils.NonTransactional); err != nil {
|
||||
@@ -818,54 +814,7 @@ func testOnStorITGetRatingPlan(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITSetRatingPlan(t *testing.T) {
|
||||
rp := &RatingPlan{
|
||||
Id: "SetRatingPlan",
|
||||
Timings: map[string]*RITiming{
|
||||
"59a981b9": &RITiming{
|
||||
Years: utils.Years{},
|
||||
Months: utils.Months{},
|
||||
MonthDays: utils.MonthDays{},
|
||||
WeekDays: utils.WeekDays{1, 2, 3, 4, 5},
|
||||
StartTime: "00:00:00",
|
||||
},
|
||||
},
|
||||
Ratings: map[string]*RIRate{
|
||||
"ebefae11": &RIRate{
|
||||
ConnectFee: 0,
|
||||
Rates: []*Rate{
|
||||
&Rate{
|
||||
GroupIntervalStart: 0,
|
||||
Value: 0.2,
|
||||
RateIncrement: time.Second,
|
||||
RateUnit: time.Minute,
|
||||
},
|
||||
},
|
||||
RoundingMethod: utils.ROUNDING_MIDDLE,
|
||||
RoundingDecimals: 4,
|
||||
},
|
||||
},
|
||||
DestinationRates: map[string]RPRateList{
|
||||
"GERMANY": []*RPRate{
|
||||
&RPRate{
|
||||
Timing: "59a981b9",
|
||||
Rating: "ebefae11",
|
||||
Weight: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := onStor.SetRatingPlan(rp, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.GetRatingPlan(rp.Id, true, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(rp, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", rp, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITGetRatingProfile(t *testing.T) {
|
||||
func testOnStorITCRUDRatingProfile(t *testing.T) {
|
||||
rpf := &RatingProfile{
|
||||
Id: "*out:test:1:trp",
|
||||
RatingPlanActivations: RatingPlanActivations{
|
||||
@@ -887,48 +836,6 @@ func testOnStorITGetRatingProfile(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(rpf, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", rpf, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITSetRatingProfile(t *testing.T) {
|
||||
rpf := &RatingProfile{
|
||||
Id: "*out:test:2:trp",
|
||||
RatingPlanActivations: RatingPlanActivations{
|
||||
&RatingPlanActivation{
|
||||
ActivationTime: time.Date(2013, 10, 1, 0, 0, 0, 0, time.UTC).Local(),
|
||||
RatingPlanId: "TDRT",
|
||||
FallbackKeys: []string{"*out:test:2:danb", "*out:test:2:rif"},
|
||||
CdrStatQueueIds: []string{},
|
||||
}},
|
||||
}
|
||||
if err := onStor.SetRatingProfile(rpf, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.GetRatingProfile(rpf.Id, true, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(rpf, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", rpf, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITRemoveRatingProfile(t *testing.T) {
|
||||
rpf := &RatingProfile{
|
||||
Id: "*out:test:3:trp",
|
||||
RatingPlanActivations: RatingPlanActivations{
|
||||
&RatingPlanActivation{
|
||||
ActivationTime: time.Date(2013, 10, 1, 0, 0, 0, 0, time.UTC).Local(),
|
||||
RatingPlanId: "TDRT",
|
||||
FallbackKeys: []string{"*out:test:3:danb", "*out:test:3:rif"},
|
||||
CdrStatQueueIds: []string{},
|
||||
}},
|
||||
}
|
||||
if err := onStor.SetRatingProfile(rpf, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.GetRatingProfile(rpf.Id, true, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(rpf, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", rpf, rcv)
|
||||
}
|
||||
if err = onStor.RemoveRatingProfile(rpf.Id, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -937,8 +844,8 @@ func testOnStorITRemoveRatingProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITGetDestination(t *testing.T) {
|
||||
dst := &Destination{Id: "GetDestination", Prefixes: []string{"+491", "+492", "+493"}}
|
||||
func testOnStorITCRUDDestination(t *testing.T) {
|
||||
dst := &Destination{Id: "CRUDDestination", Prefixes: []string{"+491", "+492", "+493"}}
|
||||
if _, rcvErr := onStor.GetDestination(dst.Id, true, utils.NonTransactional); rcvErr != utils.ErrNotFound {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
@@ -950,30 +857,6 @@ func testOnStorITGetDestination(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(dst, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", dst, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITSetDestination(t *testing.T) {
|
||||
dst := &Destination{Id: "SetDestination", Prefixes: []string{"+491", "+492", "+493"}}
|
||||
if err := onStor.SetDestination(dst, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.GetDestination(dst.Id, true, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(dst, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", dst, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITRemoveDestination(t *testing.T) {
|
||||
dst := &Destination{Id: "RemoveDestination", Prefixes: []string{"+491", "+492", "+493"}}
|
||||
if err := onStor.SetDestination(dst, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.GetDestination(dst.Id, true, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(dst, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", dst, rcv)
|
||||
}
|
||||
if err = onStor.RemoveDestination(dst.Id, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -983,8 +866,9 @@ func testOnStorITRemoveDestination(t *testing.T) {
|
||||
}
|
||||
|
||||
/* FixMe
|
||||
func testOnStorITGetReverseDestination(t *testing.T) {
|
||||
dst := &Destination{Id: "GetReverseDestination", Prefixes: []string{"+491", "+492", "+493"}}
|
||||
func testOnStorITCRUDReverseDestination(t *testing.T) {
|
||||
dst := &Destination{Id: "CRUDReverseDestination", Prefixes: []string{"+491", "+492", "+493"}}
|
||||
dst2 := &Destination{Id: "CRUDReverseDestination2", Prefixes: []string{"+491", "+492", "+493"}}
|
||||
if _, rcvErr := onStor.GetReverseDestination(dst.Id, true, utils.NonTransactional); rcvErr == err {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
@@ -996,5 +880,13 @@ func testOnStorITGetReverseDestination(t *testing.T) {
|
||||
} else if !reflect.DeepEqual([]string{dst.Id}, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", dst, rcv)
|
||||
}
|
||||
if err := onStor.UpdateReverseDestination(dst,dst2, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.GetReverseDestination(dst2.Id, true, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual([]string{dst2.Id}, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", dst2, rcv)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user