diff --git a/migrator/accounts.go b/migrator/accounts.go index 30d9f7a5d..6121f4e68 100644 --- a/migrator/accounts.go +++ b/migrator/accounts.go @@ -73,7 +73,7 @@ func (b *v1Balance) IsDefault() bool { b.Disabled == false } -func (v1Acc v1Account) AsAccount() (ac engine.Account, err error) { +func (v1Acc v1Account) AsAccount() (ac engine.Account) { // transfer data into new structurse ac = engine.Account{ ID: v1Acc.Id, diff --git a/migrator/accounts_test.go b/migrator/accounts_test.go index 6525d865a..af782d3f6 100644 --- a/migrator/accounts_test.go +++ b/migrator/accounts_test.go @@ -34,9 +34,8 @@ func TestV1AccountAsAccount(t *testing.T) { if def := v1b.IsDefault(); def != false { t.Errorf("Expecting: false, received: true") } - if newAcc, err := v1Acc.AsAccount(); err != nil { - t.Error(err) - } else if !reflect.DeepEqual(*testAccount, newAcc) { + newAcc := v1Acc.AsAccount() + if !reflect.DeepEqual(*testAccount, newAcc) { t.Errorf("Expecting: %+v, received: %+v", *testAccount, newAcc) } } diff --git a/migrator/action.go b/migrator/action.go index 12154ef7b..e73e88efd 100644 --- a/migrator/action.go +++ b/migrator/action.go @@ -35,7 +35,7 @@ type v1Action struct { type v1Actions []*v1Action -func (v1Act v1Action) AsAction() (act engine.Action, err error) { +func (v1Act v1Action) AsAction() (act engine.Action) { act = engine.Action{ Id: v1Act.Id, ActionType: v1Act.ActionType, diff --git a/migrator/action_plan.go b/migrator/action_plan.go index 2d0a4bb6b..0c4e56019 100644 --- a/migrator/action_plan.go +++ b/migrator/action_plan.go @@ -46,7 +46,7 @@ func (at *v1ActionPlan) IsASAP() bool { return at.Timing.Timing.StartTime == utils.ASAP } -func (v1AP v1ActionPlan) AsActionPlan() (ap engine.ActionPlan, err error) { +func (v1AP v1ActionPlan) AsActionPlan() (ap engine.ActionPlan) { for idx, actionId := range v1AP.AccountIds { idElements := strings.Split(actionId, utils.CONCATENATED_KEY_SEP) if len(idElements) != 3 { diff --git a/migrator/action_plan_test.go b/migrator/action_plan_test.go index 182de48a0..8b4135559 100644 --- a/migrator/action_plan_test.go +++ b/migrator/action_plan_test.go @@ -28,9 +28,8 @@ import ( func TestV1ActionPlanAsActionPlan(t *testing.T) { v1ap := &v1ActionPlan{Id: "test", AccountIds: []string{"one"}, Timing: &engine.RateInterval{Timing: new(engine.RITiming)}} ap := &engine.ActionPlan{Id: "test", AccountIDs: utils.StringMap{"one": true}, ActionTimings: []*engine.ActionTiming{&engine.ActionTiming{Timing: &engine.RateInterval{Timing: new(engine.RITiming)}}}} - if newap, err := v1ap.AsActionPlan(); err != nil { - t.Error(err) - } else if ap.Id != newap.Id || !reflect.DeepEqual(ap.AccountIDs, newap.AccountIDs) { + newap := v1ap.AsActionPlan() + if ap.Id != newap.Id || !reflect.DeepEqual(ap.AccountIDs, newap.AccountIDs) { t.Errorf("Expecting: %+v, received: %+v", *ap, newap) } else if !reflect.DeepEqual(ap.ActionTimings[0].Timing, newap.ActionTimings[0].Timing) { t.Errorf("Expecting: %+v, received: %+v", ap.ActionTimings[0].Timing, newap.ActionTimings[0].Timing) diff --git a/migrator/action_test.go b/migrator/action_test.go index dbc0c8063..db29d3db6 100644 --- a/migrator/action_test.go +++ b/migrator/action_test.go @@ -27,9 +27,8 @@ import ( func TestV1ActionsAsActions(t *testing.T) { v1act := &v1Action{Id: "", ActionType: "", BalanceType: "", Direction: "INBOUND", ExtraParameters: "", ExpirationString: "", Balance: &v1Balance{}} act := &engine.Action{Id: "", ActionType: "", ExtraParameters: "", ExpirationString: "", Weight: 0.00, Balance: &engine.BalanceFilter{}} - if newact, err := v1act.AsAction(); err != nil { - t.Error(err) - } else if !reflect.DeepEqual(*act, newact) { + newact := v1act.AsAction() + if !reflect.DeepEqual(*act, newact) { t.Errorf("Expecting: %+v, received: %+v", *act, newact) } } diff --git a/migrator/action_trigger.go b/migrator/action_trigger.go index 765d1ba57..862115352 100644 --- a/migrator/action_trigger.go +++ b/migrator/action_trigger.go @@ -33,7 +33,8 @@ type v1ActionTrigger struct { type v1ActionTriggers []*v1ActionTrigger -func (v1Act v1ActionTrigger) AsActionTrigger() (at engine.ActionTrigger, err error) { +func (v1Act v1ActionTrigger) AsActionTrigger() (at engine.ActionTrigger) { + at = engine.ActionTrigger{ UniqueID: v1Act.Id, ThresholdType: v1Act.ThresholdType, diff --git a/migrator/action_trigger_test.go b/migrator/action_trigger_test.go index 55964bef0..e9cc646e8 100644 --- a/migrator/action_trigger_test.go +++ b/migrator/action_trigger_test.go @@ -43,9 +43,8 @@ func TestV1ActionTriggersAsActionTriggers(t *testing.T) { if err := json.Unmarshal([]byte(v1ActionTriggers1), &v1actstrgrs); err != nil { t.Error(err) } - if newatrs, err := v1actstrgrs.AsActionTrigger(); err != nil { - t.Error(err) - } else if !reflect.DeepEqual(*atrs, newatrs) { + newatrs := v1actstrgrs.AsActionTrigger() + if !reflect.DeepEqual(*atrs, newatrs) { t.Errorf("Expecting: %+v, received: %+v", *atrs, newatrs) } } diff --git a/migrator/costdetails.go b/migrator/costdetails.go index 7d2755b61..67095994d 100644 --- a/migrator/costdetails.go +++ b/migrator/costdetails.go @@ -89,8 +89,8 @@ func (m *Migrator) migrateCostDetails() (err error) { v1CC := &v1CallCost{Direction: ccDirection.String, Category: ccCategory.String, Tenant: ccTenant.String, Subject: ccSubject.String, Account: ccAccount.String, Destination: ccDestination.String, TOR: ccTor.String, Cost: ccCost.Float64, Timespans: v1tmsps} - cc, err := v1CC.AsCallCost() - if err != nil { + cc := v1CC.AsCallCost() + if cc == nil { utils.Logger.Warning( fmt.Sprintf(" Error: <%s> when converting into CallCost CDR with id: <%d>", err.Error(), id)) continue @@ -152,7 +152,7 @@ type v1UnitInfo struct { TOR string } -func (v1cc *v1CallCost) AsCallCost() (cc *engine.CallCost, err error) { +func (v1cc *v1CallCost) AsCallCost() (cc *engine.CallCost) { cc = new(engine.CallCost) cc.Direction = v1cc.Direction cc.Category = v1cc.Category diff --git a/migrator/costdetails_test.go b/migrator/costdetails_test.go index 84d8297de..9b101bbdf 100644 --- a/migrator/costdetails_test.go +++ b/migrator/costdetails_test.go @@ -31,9 +31,7 @@ func TestV1CostDetailsAsCostDetails1(t *testing.T) { t.Error(err) } v1CC := &v1CallCost{Timespans: v1tmsps} - if _, err := v1CC.AsCallCost(); err != nil { - t.Error(err) - } + _ = v1CC.AsCallCost() // ToDo: Test here the content } @@ -44,7 +42,6 @@ func TestV1CostDetailsAsCostDetails2(t *testing.T) { t.Error(err) } v1CC := &v1CallCost{Timespans: v1tmsps} - if _, err := v1CC.AsCallCost(); err != nil { - t.Error(err) - } + _ = v1CC.AsCallCost() + }