From 54133db99b818a1409b0b6e27f8ec8d45b9948f2 Mon Sep 17 00:00:00 2001 From: edwardro22 Date: Wed, 13 Sep 2017 15:08:24 +0000 Subject: [PATCH] Formated code --- apier/v1/tpresources_it_test.go | 1 + engine/libtest.go | 4 ++-- engine/loader_csv_test.go | 18 +++++++++--------- engine/model_helpers.go | 16 ++++++++-------- engine/model_helpers_test.go | 18 +++++++++--------- engine/models.go | 4 ++-- engine/resources.go | 6 +++--- engine/storage_sql.go | 2 +- engine/stordb_it_test.go | 6 +++--- 9 files changed, 38 insertions(+), 37 deletions(-) diff --git a/apier/v1/tpresources_it_test.go b/apier/v1/tpresources_it_test.go index 37f7c62a8..a49521dce 100644 --- a/apier/v1/tpresources_it_test.go +++ b/apier/v1/tpresources_it_test.go @@ -127,6 +127,7 @@ func testTPResGetTPResourceBeforeSet(t *testing.T) { func testTPResSetTPResource(t *testing.T) { tpRes = &utils.TPResource{ + Tenant:"Tester", TPid: "TPR1", ID: "Res", Filters: []*utils.TPRequestFilter{ diff --git a/engine/libtest.go b/engine/libtest.go index b203f7424..705dfcdd9 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -42,8 +42,8 @@ func InitDataDb(cfg *config.CGRConfig) error { return err } dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) - // Write version before starting - if err := CheckVersions(dataDB); err != nil { + // Write version before starting + if err := CheckVersions(dataDB); err != nil { return err } diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 798aa0a4a..7c13357f8 100755 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -1392,9 +1392,9 @@ func TestLoadReverseAliases(t *testing.T) { func TestLoadResourceProfiles(t *testing.T) { eResProfiles := map[string]*utils.TPResource{ "ResGroup21": &utils.TPResource{ - TPid: testTPID, - Tenant:"Tester", - ID: "ResGroup21", + TPid: testTPID, + Tenant: "Tester", + ID: "ResGroup21", Filters: []*utils.TPRequestFilter{ &utils.TPRequestFilter{Type: MetaString, FieldName: "HdrAccount", Values: []string{"1001", "1002"}}, &utils.TPRequestFilter{Type: MetaStringPrefix, FieldName: "HdrDestination", Values: []string{"10", "20"}}, @@ -1409,9 +1409,9 @@ func TestLoadResourceProfiles(t *testing.T) { Limit: "2", }, "ResGroup22": &utils.TPResource{ - TPid: testTPID, - Tenant:"Tester", - ID: "ResGroup22", + TPid: testTPID, + Tenant: "Tester", + ID: "ResGroup22", Filters: []*utils.TPRequestFilter{ &utils.TPRequestFilter{Type: MetaDestinations, FieldName: "HdrDestination", Values: []string{"DST_FS"}}, }, @@ -1438,9 +1438,9 @@ func TestLoadResourceProfiles(t *testing.T) { func TestLoadStats(t *testing.T) { eStats := map[string]*utils.TPStats{ "Stats1": &utils.TPStats{ - Tenant:"Tester", - TPid: testTPID, - ID: "Stats1", + Tenant: "Tester", + TPid: testTPID, + ID: "Stats1", Filters: []*utils.TPRequestFilter{ &utils.TPRequestFilter{Type: MetaString, FieldName: "Account", Values: []string{"1001", "1002"}}, }, diff --git a/engine/model_helpers.go b/engine/model_helpers.go index b06b5cce8..c34ea2175 100755 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -1880,9 +1880,9 @@ func APItoModelResource(rl *utils.TPResource) (mdls TpResources) { } for i, fltr := range rl.Filters { mdl := &TpResource{ - Tpid: rl.TPid, - Tenant: rl.Tenant, - Tag: rl.ID, + Tpid: rl.TPid, + Tenant: rl.Tenant, + Tag: rl.ID, } if i == 0 { mdl.UsageTTL = rl.UsageTTL @@ -1963,7 +1963,7 @@ func (tps TpStatsS) AsTPStats() (result []*utils.TPStats) { st, found := mst[tp.Tag] if !found { st = &utils.TPStats{ - Tenant: tp.Tenant, + Tenant: tp.Tenant, TPid: tp.Tpid, ID: tp.Tag, Blocker: tp.Blocker, @@ -2031,9 +2031,9 @@ func APItoModelStats(st *utils.TPStats) (mdls TpStatsS) { } for i, fltr := range st.Filters { mdl := &TpStats{ - Tenant: st.Tenant, - Tpid: st.TPid, - Tag: st.ID, + Tenant: st.Tenant, + Tpid: st.TPid, + Tag: st.ID, } if i == 0 { mdl.TTL = st.TTL @@ -2077,7 +2077,7 @@ func APItoModelStats(st *utils.TPStats) (mdls TpStatsS) { func APItoStats(tpST *utils.TPStats, timezone string) (st *StatQueueProfile, err error) { st = &StatQueueProfile{ - Tenant: tpST.Tenant, + Tenant: tpST.Tenant, ID: tpST.ID, QueueLength: tpST.QueueLength, Weight: tpST.Weight, diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index bc57d7df3..bad16444a 100755 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -713,7 +713,7 @@ func TestTpResourcesAsTpResources(t *testing.T) { tps := []*TpResource{ &TpResource{ Tpid: "TEST_TPID", - Tenant: "Tester", + Tenant: "Tester", Tag: "ResGroup1", FilterType: MetaStringPrefix, FilterFieldName: "Destination", @@ -727,14 +727,14 @@ func TestTpResourcesAsTpResources(t *testing.T) { &TpResource{ Tpid: "TEST_TPID", Tag: "ResGroup1", - Tenant: "Tester", + Tenant: "Tester", FilterType: MetaStringPrefix, FilterFieldName: "Category", FilterFieldValues: "call;inbound_call", Thresholds: "WARN3"}, &TpResource{ Tpid: "TEST_TPID", - Tenant: "Tester", + Tenant: "Tester", Tag: "ResGroup2", FilterType: MetaStringPrefix, FilterFieldName: "Destination", @@ -747,9 +747,9 @@ func TestTpResourcesAsTpResources(t *testing.T) { } eTPs := []*utils.TPResource{ &utils.TPResource{ - TPid: tps[0].Tpid, - Tenant: tps[0].Tenant, - ID: tps[0].Tag, + TPid: tps[0].Tpid, + Tenant: tps[0].Tenant, + ID: tps[0].Tag, Filters: []*utils.TPRequestFilter{ &utils.TPRequestFilter{ Type: tps[0].FilterType, @@ -772,9 +772,9 @@ func TestTpResourcesAsTpResources(t *testing.T) { Thresholds: []string{"WARN_RES1", "WARN_RES2", "WARN3"}, }, &utils.TPResource{ - TPid: tps[2].Tpid, - Tenant: tps[2].Tenant, - ID: tps[2].Tag, + TPid: tps[2].Tpid, + Tenant: tps[2].Tenant, + ID: tps[2].Tag, Filters: []*utils.TPRequestFilter{ &utils.TPRequestFilter{ Type: tps[2].FilterType, diff --git a/engine/models.go b/engine/models.go index 8b7fd037a..e769f00a9 100755 --- a/engine/models.go +++ b/engine/models.go @@ -454,7 +454,7 @@ func (t TBLSMCosts) TableName() string { type TpResource struct { ID int64 Tpid string - Tenant string `index:"0" re:""` + Tenant string `index:"0" re:""` Tag string `index:"1" re:""` FilterType string `index:"2" re:"^\*[A-Za-z].*"` FilterFieldName string `index:"3" re:""` @@ -483,7 +483,7 @@ func (t TBLVersion) TableName() string { type TpStats struct { ID int64 Tpid string - Tenant string `index:"0" re:""` + Tenant string `index:"0" re:""` Tag string `index:"1" re:""` FilterType string `index:"2" re:"^\*[A-Za-z].*"` FilterFieldName string `index:"3" re:""` diff --git a/engine/resources.go b/engine/resources.go index 357f1b60b..40a2c5ba7 100755 --- a/engine/resources.go +++ b/engine/resources.go @@ -39,7 +39,7 @@ func init() { // ResourceProfile represents the user configuration for the resource type ResourceProfile struct { - Tenant string + Tenant string ID string // identifier of this resource Filters []*RequestFilter // filters for the request ActivationInterval *utils.ActivationInterval // time when this resource becomes active and expires @@ -54,7 +54,7 @@ type ResourceProfile struct { // ResourceUsage represents an usage counted type ResourceUsage struct { - Tenant string + Tenant string ID string // Unique identifier of this ResourceUsage, Eg: FreeSWITCH UUID ExpiryTime time.Time Units float64 // Number of units used @@ -68,7 +68,7 @@ func (ru *ResourceUsage) isActive(atTime time.Time) bool { // Resource represents a resource in the system // not thread safe, needs locking at process level type Resource struct { - Tenant string + Tenant string ID string Usages map[string]*ResourceUsage TTLIdx []string // holds ordered list of ResourceIDs based on their TTL, empty if feature is disabled diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 7d6bb583a..fdf8c4de5 100755 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -587,7 +587,7 @@ func (self *SQLStorage) SetTPStats(sts []*utils.TPStats) error { tx := self.db.Begin() for _, stq := range sts { // Remove previous - if err := tx.Where(&TpStats{Tpid: stq.TPid,Tag: stq.ID}).Delete(TpStats{}).Error; err != nil { + if err := tx.Where(&TpStats{Tpid: stq.TPid, Tag: stq.ID}).Delete(TpStats{}).Error; err != nil { tx.Rollback() return err } diff --git a/engine/stordb_it_test.go b/engine/stordb_it_test.go index 3d4f5ab12..b2aae4f4b 100755 --- a/engine/stordb_it_test.go +++ b/engine/stordb_it_test.go @@ -1540,9 +1540,9 @@ func testStorDBitCRUDTpStats(t *testing.T) { //WRITE eTPs := []*utils.TPStats{ &utils.TPStats{ - TPid: "TEST_TPID", - Tenant:"Test", - ID: "Stats1", + TPid: "TEST_TPID", + Tenant: "Test", + ID: "Stats1", Filters: []*utils.TPRequestFilter{ &utils.TPRequestFilter{ Type: "filtertype",