mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
Updating integration tests with RatingProfiles.csv changes
This commit is contained in:
@@ -678,10 +678,9 @@ func testOnStorITRatingProfile(t *testing.T) {
|
||||
Id: "*out:test:1:trp",
|
||||
RatingPlanActivations: RatingPlanActivations{
|
||||
&RatingPlanActivation{
|
||||
ActivationTime: time.Date(2013, 10, 1, 0, 0, 0, 0, time.UTC),
|
||||
RatingPlanId: "TDRT",
|
||||
FallbackKeys: []string{"*out:test:1:danb", "*out:test:1:rif"},
|
||||
CdrStatQueueIds: []string{},
|
||||
ActivationTime: time.Date(2013, 10, 1, 0, 0, 0, 0, time.UTC),
|
||||
RatingPlanId: "TDRT",
|
||||
FallbackKeys: []string{"*out:test:1:danb", "*out:test:1:rif"},
|
||||
}},
|
||||
}
|
||||
if _, rcvErr := onStor.GetRatingProfile(rpf.Id, false,
|
||||
@@ -716,10 +715,9 @@ func testOnStorITRatingProfile(t *testing.T) {
|
||||
//update
|
||||
rpf.RatingPlanActivations = RatingPlanActivations{
|
||||
&RatingPlanActivation{
|
||||
ActivationTime: time.Date(2013, 10, 1, 0, 0, 0, 0, time.UTC),
|
||||
RatingPlanId: "TDRT",
|
||||
FallbackKeys: []string{"*out:test:1:danb", "*out:test:1:teo"},
|
||||
CdrStatQueueIds: []string{},
|
||||
ActivationTime: time.Date(2013, 10, 1, 0, 0, 0, 0, time.UTC),
|
||||
RatingPlanId: "TDRT",
|
||||
FallbackKeys: []string{"*out:test:1:danb", "*out:test:1:teo"},
|
||||
},
|
||||
}
|
||||
if err := onStor.SetRatingProfile(rpf, utils.NonTransactional); err != nil {
|
||||
|
||||
@@ -277,6 +277,7 @@ func (self *SQLStorage) SetTPTimings(timings []*utils.ApierTPTiming) error {
|
||||
}
|
||||
t := APItoModelTiming(timing)
|
||||
if err := tx.Save(&t).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -297,15 +298,10 @@ func (self *SQLStorage) SetTPDestinations(dests []*utils.TPDestination) error {
|
||||
}
|
||||
for _, d := range APItoModelDestination(dst) {
|
||||
if err := tx.Save(&d).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
// for _, dstPrfx := range dst.Prefixes {
|
||||
// if err := tx.Save(&TpDestination{Tpid: dst.TPid, Tag: dst.Tag, Prefix: dstPrfx}).Error; err != nil {
|
||||
// tx.Rollback()
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
}
|
||||
tx.Commit()
|
||||
return nil
|
||||
@@ -327,6 +323,7 @@ func (self *SQLStorage) SetTPRates(rs []*utils.TPRate) error {
|
||||
}
|
||||
for _, r := range APItoModelRate(rate) {
|
||||
if err := tx.Save(&r).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -351,6 +348,7 @@ func (self *SQLStorage) SetTPDestinationRates(drs []*utils.TPDestinationRate) er
|
||||
}
|
||||
for _, d := range APItoModelDestinationRate(dRate) {
|
||||
if err := tx.Save(&d).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -375,6 +373,7 @@ func (self *SQLStorage) SetTPRatingPlans(rps []*utils.TPRatingPlan) error {
|
||||
}
|
||||
for _, r := range APItoModelRatingPlan(rPlan) {
|
||||
if err := tx.Save(&r).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -397,6 +396,7 @@ func (self *SQLStorage) SetTPRatingProfiles(rpfs []*utils.TPRatingProfile) error
|
||||
}
|
||||
for _, r := range APItoModelRatingProfile(rpf) {
|
||||
if err := tx.Save(&r).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -421,6 +421,7 @@ func (self *SQLStorage) SetTPSharedGroups(sgs []*utils.TPSharedGroups) error {
|
||||
}
|
||||
for _, s := range APItoModelSharedGroup(sGroup) {
|
||||
if err := tx.Save(&s).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -453,6 +454,7 @@ func (self *SQLStorage) SetTPDerivedChargers(sgs []*utils.TPDerivedChargers) err
|
||||
}
|
||||
for _, d := range APItoModelDerivedCharger(dCharger) {
|
||||
if err := tx.Save(&d).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -477,6 +479,7 @@ func (self *SQLStorage) SetTPActions(acts []*utils.TPActions) error {
|
||||
}
|
||||
for _, sa := range APItoModelAction(a) {
|
||||
if err := tx.Save(&sa).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -502,6 +505,7 @@ func (self *SQLStorage) SetTPActionPlans(ats []*utils.TPActionPlan) error {
|
||||
}
|
||||
for _, a := range APItoModelActionPlan(aPlan) {
|
||||
if err := tx.Save(&a).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -526,6 +530,7 @@ func (self *SQLStorage) SetTPActionTriggers(ats []*utils.TPActionTriggers) error
|
||||
}
|
||||
for _, a := range APItoModelActionTrigger(aTrigger) {
|
||||
if err := tx.Save(&a).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -552,6 +557,7 @@ func (self *SQLStorage) SetTPAccountActions(aas []*utils.TPAccountActions) error
|
||||
}
|
||||
sa := APItoModelAccountAction(aa)
|
||||
if err := tx.Save(&sa).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1401,6 +1407,7 @@ func (self *SQLStorage) SetTPUsers(users []*utils.TPUsers) error {
|
||||
}
|
||||
for _, u := range APItoModelUsers(user) {
|
||||
if err := tx.Save(&u).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1455,6 +1462,7 @@ func (self *SQLStorage) SetTPAliases(aliases []*utils.TPAliases) error {
|
||||
}
|
||||
for _, a := range APItoModelAliases(alias) {
|
||||
if err := tx.Save(&a).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,34 +517,30 @@ func testStorDBitCRUDTpRatingProfiles(t *testing.T) {
|
||||
// WRITE
|
||||
var snd = []*utils.TPRatingProfile{
|
||||
{
|
||||
TPid: "testTPid",
|
||||
LoadId: "TEST_LOADID",
|
||||
Direction: "*out",
|
||||
Tenant: "cgrates.org",
|
||||
Category: "call",
|
||||
Subject: "test",
|
||||
TPid: "testTPid",
|
||||
LoadId: "TEST_LOADID",
|
||||
Tenant: "cgrates.org",
|
||||
Category: "call",
|
||||
Subject: "test",
|
||||
RatingPlanActivations: []*utils.TPRatingActivation{
|
||||
{
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
RatingPlanId: "test",
|
||||
FallbackSubjects: "",
|
||||
CdrStatQueueIds: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
TPid: "testTPid",
|
||||
LoadId: "TEST_LOADID2",
|
||||
Direction: "*out",
|
||||
Tenant: "cgrates.org",
|
||||
Category: "call",
|
||||
Subject: "test",
|
||||
TPid: "testTPid",
|
||||
LoadId: "TEST_LOADID2",
|
||||
Tenant: "cgrates.org",
|
||||
Category: "call",
|
||||
Subject: "test",
|
||||
RatingPlanActivations: []*utils.TPRatingActivation{
|
||||
{
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
RatingPlanId: "test",
|
||||
FallbackSubjects: "",
|
||||
CdrStatQueueIds: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -556,13 +552,25 @@ func testStorDBitCRUDTpRatingProfiles(t *testing.T) {
|
||||
if rcv, err := storDB.GetTPRatingProfiles(&filter); err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
if !(reflect.DeepEqual(snd[0], rcv[0]) || reflect.DeepEqual(snd[0], rcv[1])) {
|
||||
t.Errorf("\nExpecting:\n%+v\nReceived:\n%+v\n||\n%+v", utils.ToIJSON(snd[0]), utils.ToIJSON(rcv[0]), utils.ToIJSON(rcv[1]))
|
||||
if !(reflect.DeepEqual(snd[0], rcv[0]) ||
|
||||
reflect.DeepEqual(snd[0], rcv[1])) {
|
||||
t.Errorf("\nExpecting:\n%+v\nReceived:\n%+v\n||\n%+v",
|
||||
utils.ToIJSON(snd[0]), utils.ToIJSON(rcv[0]), utils.ToIJSON(rcv[1]))
|
||||
}
|
||||
}
|
||||
// UPDATE
|
||||
snd[0].RatingPlanActivations[0].CdrStatQueueIds = "test"
|
||||
snd[1].RatingPlanActivations[0].CdrStatQueueIds = "test"
|
||||
snd[0].RatingPlanActivations = append(snd[0].RatingPlanActivations,
|
||||
&utils.TPRatingActivation{
|
||||
ActivationTime: "2019-02-11T15:00:00Z",
|
||||
RatingPlanId: "test",
|
||||
FallbackSubjects: "",
|
||||
})
|
||||
snd[1].RatingPlanActivations = append(snd[1].RatingPlanActivations,
|
||||
&utils.TPRatingActivation{
|
||||
ActivationTime: "2019-02-11T15:00:00Z",
|
||||
RatingPlanId: "test",
|
||||
FallbackSubjects: "",
|
||||
})
|
||||
if err := storDB.SetTPRatingProfiles(snd); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -571,7 +579,8 @@ func testStorDBitCRUDTpRatingProfiles(t *testing.T) {
|
||||
t.Error(err)
|
||||
} else {
|
||||
if !(reflect.DeepEqual(snd[0], rcv[0]) || reflect.DeepEqual(snd[0], rcv[1])) {
|
||||
t.Errorf("\nExpecting:\n%+v\nReceived:\n%+v\n||\n%+v", utils.ToIJSON(snd[0]), utils.ToIJSON(rcv[0]), utils.ToIJSON(rcv[1]))
|
||||
t.Errorf("\nExpecting:\n%+v\nReceived:\n%+v\n||\n%+v",
|
||||
utils.ToIJSON(snd[0]), utils.ToIJSON(rcv[0]), utils.ToIJSON(rcv[1]))
|
||||
}
|
||||
}
|
||||
// REMOVE
|
||||
@@ -831,7 +840,6 @@ func testStorDBitCRUDTpActionTriggers(t *testing.T) {
|
||||
ActivationDate: "2014-07-29T15:00:00Z",
|
||||
BalanceId: "test",
|
||||
BalanceType: "*monetary",
|
||||
BalanceDirections: "*out",
|
||||
BalanceDestinationIds: "call",
|
||||
BalanceWeight: "0.0",
|
||||
BalanceExpirationDate: "2014-07-29T15:00:00Z",
|
||||
@@ -841,7 +849,6 @@ func testStorDBitCRUDTpActionTriggers(t *testing.T) {
|
||||
BalanceSharedGroups: "SHARED_1",
|
||||
BalanceBlocker: "false",
|
||||
BalanceDisabled: "false",
|
||||
MinQueuedItems: 0,
|
||||
ActionsId: "test",
|
||||
Weight: 1.0,
|
||||
},
|
||||
@@ -862,7 +869,6 @@ func testStorDBitCRUDTpActionTriggers(t *testing.T) {
|
||||
ActivationDate: "2014-07-29T15:00:00Z",
|
||||
BalanceId: "test",
|
||||
BalanceType: "*monetary",
|
||||
BalanceDirections: "*out",
|
||||
BalanceDestinationIds: "call",
|
||||
BalanceWeight: "0.0",
|
||||
BalanceExpirationDate: "2014-07-29T15:00:00Z",
|
||||
@@ -872,7 +878,6 @@ func testStorDBitCRUDTpActionTriggers(t *testing.T) {
|
||||
BalanceSharedGroups: "SHARED_1",
|
||||
BalanceBlocker: "false",
|
||||
BalanceDisabled: "false",
|
||||
MinQueuedItems: 0,
|
||||
ActionsId: "test",
|
||||
Weight: 1.0,
|
||||
},
|
||||
@@ -891,8 +896,8 @@ func testStorDBitCRUDTpActionTriggers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// UPDATE
|
||||
snd[0].ActionTriggers[0].MinQueuedItems = 2
|
||||
snd[1].ActionTriggers[0].MinQueuedItems = 2
|
||||
snd[0].ActionTriggers[0].ActionsId = "test2"
|
||||
snd[1].ActionTriggers[0].ActionsId = "test2"
|
||||
if err := storDB.SetTPActionTriggers(snd); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user