From ec5adbe93fc20cbcfcf5abf70653254e2a8c4ed1 Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 11 Oct 2017 13:47:40 +0300 Subject: [PATCH] Updated test in loader_csv-test.go --- engine/loader_csv_test.go | 86 +++++++++++++++++++++++++++++++++++++-- engine/storage_map.go | 4 ++ engine/tp_reader.go | 2 + 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index c9c58758b..1b18440c7 100755 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -356,6 +356,9 @@ func init() { if err := csvr.LoadThresholds(); err != nil { log.Print("error in LoadThresholds:", err) } + if err := csvr.LoadFilter(); err != nil { + log.Print("error in LoadFilter:", err) + } csvr.WriteToDatabase(false, false, false) cache.Flush() dm.DataDB().LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) @@ -1441,12 +1444,11 @@ func TestLoadResourceProfiles(t *testing.T) { t.Errorf("Failed to load resourceProfiles: %s", utils.ToIJSON(csvr.resProfiles)) } else if !reflect.DeepEqual(eResProfiles["cgrates.org"]["ResGroup22"], csvr.resProfiles["cgrates.org"]["ResGroup22"]) { t.Errorf("Expecting: %+v, received: %+v", eResProfiles["cgrates.org"]["ResGroup22"], csvr.resProfiles["cgrates.org"]["ResGroup22"]) - } } -func TestLoadStats(t *testing.T) { +func TestLoadStatProfiles(t *testing.T) { eStats := map[string]map[string]*utils.TPStats{ "cgrates.org": map[string]*utils.TPStats{ "Stats1": &utils.TPStats{ @@ -1479,7 +1481,7 @@ func TestLoadStats(t *testing.T) { } } -func TestLoadThresholds(t *testing.T) { +func TestLoadThresholdProfiles(t *testing.T) { eThresholds := map[string]map[string]*utils.TPThreshold{ "cgrates.org": map[string]*utils.TPThreshold{ "Threshold1": &utils.TPThreshold{ @@ -1506,3 +1508,81 @@ func TestLoadThresholds(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", eThresholds["cgrates.org"]["Threshold1"], csvr.thProfiles["cgrates.org"]["Threshold1"]) } } + +func TestLoadFilterProfiles(t *testing.T) { +} + +func TestLoadResource(t *testing.T) { + eResources := []*utils.TenantID{ + &utils.TenantID{ + Tenant: "cgrates.org", + ID: "ResGroup21", + }, + &utils.TenantID{ + Tenant: "cgrates.org", + ID: "ResGroup22", + }, + } + + if len(csvr.resources) != len(eResources) { + t.Errorf("Failed to load resources: %s", utils.ToIJSON(csvr.resources)) + } else if !reflect.DeepEqual(eResources, csvr.resources) { + t.Errorf("Expecting: %+v, received: %+v", eResources, csvr.resources) + } +} + +func TestLoadstatQueues(t *testing.T) { + eStatQueues := []*utils.TenantID{ + &utils.TenantID{ + Tenant: "cgrates.org", + ID: "Stats1", + }, + } + + if len(csvr.statQueues) != len(eStatQueues) { + t.Errorf("Failed to load statQueues: %s", utils.ToIJSON(csvr.statQueues)) + } else if !reflect.DeepEqual(eStatQueues, csvr.statQueues) { + t.Errorf("Expecting: %+v, received: %+v", eStatQueues, csvr.statQueues) + } +} + +func TestLoadThresholds(t *testing.T) { + eThresholds := []*utils.TenantID{ + &utils.TenantID{ + Tenant: "cgrates.org", + ID: "Threshold1", + }, + } + + if len(csvr.thresholds) != len(eThresholds) { + t.Errorf("Failed to load thresholds: %s", utils.ToIJSON(csvr.thresholds)) + } else if !reflect.DeepEqual(eThresholds, csvr.thresholds) { + t.Errorf("Expecting: %+v, received: %+v", eThresholds, csvr.thresholds) + } +} + +/* +func TestLoadFilters(t *testing.T) { + eFilters := []*utils.TenantID{ + &utils.TenantID{ + Tenant: "cgrates.org", + ID: "Threshold1", + }, + &utils.TenantID{ + Tenant: "cgrates.org", + ID: "Threshold1", + }, + &utils.TenantID{ + Tenant: "cgrates.org", + ID: "Threshold1", + }, + } + + if len(csvr.filters) != len(eFilters) { + t.Errorf("Failed to load thresholds: %s", utils.ToIJSON(csvr.thresholds)) + } else if !reflect.DeepEqual(eThresholds, csvr.thresholds) { + t.Errorf("Expecting: %+v, received: %+v", eFilters, csvr.thresholds) + } + +} +*/ diff --git a/engine/storage_map.go b/engine/storage_map.go index 135ea6332..5e9b5c8f8 100755 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -317,7 +317,11 @@ func (ms *MapStorage) HasData(categ, subject string) (bool, error) { switch categ { case utils.DESTINATION_PREFIX, utils.RATING_PLAN_PREFIX, utils.RATING_PROFILE_PREFIX, utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACCOUNT_PREFIX, utils.DERIVEDCHARGERS_PREFIX, +<<<<<<< HEAD utils.ResourcesPrefix, utils.StatQueuePrefix, utils.ThresholdPrefix: +======= + utils.ResourcesPrefix, utils.StatQueuePrefix, utils.ThresholdProfilePrefix, utils.FilterPrefix: +>>>>>>> Add test in loader_csv_test.go for resources,statQueue,thresholds,filters _, exists := ms.dict[categ+subject] return exists, nil } diff --git a/engine/tp_reader.go b/engine/tp_reader.go index fc7feb23b..2a0651ff9 100755 --- a/engine/tp_reader.go +++ b/engine/tp_reader.go @@ -2297,6 +2297,8 @@ func (tpr *TpReader) ShowStatistics() { log.Print("Stats: ", len(tpr.sqProfiles)) // thresholds log.Print("Thresholds: ", len(tpr.thProfiles)) + // thresholds + log.Print("Filters: ", len(tpr.flProfiles)) } // Returns the identities loaded for a specific category, useful for cache reloads