From 5da4cf6d1c3f112155d511b8dce38a00f1f8edb6 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 30 Oct 2020 15:43:43 +0200 Subject: [PATCH] Updated account action plans integration tests for cache --- agents/agentreq_test.go | 18 +- agents/diam_it_test.go | 8 +- agents/diamagent_test.go | 2 +- agents/fsevent_test.go | 18 +- agents/librad_test.go | 2 +- agents/libsip_test.go | 4 +- apier/v1/apier2_it_test.go | 12 +- apier/v1/apier_it_test.go | 12 +- apier/v1/caches_it_test.go | 4 +- apier/v1/cdrs_it_test.go | 36 +- apier/v1/concreqs_it_test.go | 8 +- apier/v1/config_it_test.go | 2 +- apier/v1/ees_it_test.go | 8 +- apier/v1/filter_indexes_it_test.go | 12 +- apier/v1/filterindexecache_it_test.go | 24 +- apier/v1/precache_it_test.go | 64 +-- apier/v1/preload_it_test.go | 2 +- apier/v1/rateprofiles_it_test.go | 150 +++--- apier/v1/remote_it_test.go | 40 +- apier/v1/replicate_it_test.go | 30 +- apier/v1/resourcesv1_it_test.go | 8 +- apier/v1/routes_it_test.go | 18 +- apier/v1/sessions_thresholds_it_test.go | 10 +- apier/v1/sessionsv1_it_test.go | 2 +- apier/v1/stats_it_test.go | 46 +- apier/v1/thresholds_it_test.go | 12 +- apier/v1/tpaccountactions_it_test.go | 2 +- apier/v1/tpratingprofiles_it_test.go | 2 +- apier/v2/apierv2_it_test.go | 4 +- apier/v2/cdrs_it_test.go | 4 +- apier/v2/cdrs_offline_it_test.go | 16 +- cmd/cgr-console/cgr-console.go | 2 +- cmd/cgr-tester/cdr_repl/process_cdr.go | 2 +- config/cachecfg_test.go | 8 +- config/config_test.go | 32 +- config/dispatcherhcfg_test.go | 4 +- config/eescfg_test.go | 8 +- config/erscfg_test.go | 32 +- config/multifiles_it_test.go | 6 +- config/ralscfg_test.go | 10 +- config/resourcescfg_test.go | 2 +- config/sessionscfg_test.go | 23 +- config/sipagentcfg_test.go | 4 +- config/statscfg_test.go | 3 +- config/thresholdscfg_test.go | 3 +- dispatchers/caches_it_test.go | 1 - dispatchers/cdrs_it_test.go | 16 +- dispatchers/rals_it_test.go | 2 +- dispatchers/sessions_it_test.go | 2 +- dispatchers/stats_it_test.go | 12 +- ees/elastic_it_test.go | 4 +- ees/filecsv_it_test.go | 28 +- ees/filefwv_it_test.go | 4 +- ees/httpjsonmap_it_test.go | 6 +- ees/httppost_it_test.go | 6 +- ees/virtual_ee_it_test.go | 6 +- engine/account_test.go | 6 +- engine/action_trigger_test.go | 4 +- engine/actions_test.go | 2 +- engine/calldesc_test.go | 14 +- engine/cdr_test.go | 48 +- engine/cgrcdr_test.go | 4 +- engine/chargers_test.go | 2 +- engine/eventcost_test.go | 516 ++++++++++---------- engine/filters_test.go | 10 +- engine/fscdr_test.go | 2 +- engine/libcdre_test.go | 4 +- engine/libeventcost_test.go | 76 +-- engine/libstats_test.go | 22 +- engine/mapevent_test.go | 74 +-- engine/model_helpers_test.go | 52 +- engine/rateinterval_test.go | 30 +- engine/rateprofile_test.go | 134 ++--- engine/ratingplan_test.go | 18 +- engine/responder_test.go | 66 +-- engine/routes.go | 2 +- engine/routes_test.go | 6 +- engine/safevent_test.go | 46 +- engine/statmetrics_test.go | 242 ++++----- engine/stats_test.go | 24 +- engine/storage_mongo_datadb.go | 4 +- engine/suretax_test.go | 2 +- engine/thresholds_test.go | 4 +- engine/timespans_test.go | 36 +- engine/z_actions_it_test.go | 24 +- engine/z_attributes_test.go | 4 +- engine/z_filterindexer_it_test.go | 41 +- engine/z_onstor_it_test.go | 14 +- engine/z_poster_it_test.go | 12 +- engine/z_resources_test.go | 46 +- engine/z_storage_cdrs_it_test.go | 4 +- ers/ers_test.go | 3 +- ers/filecsv_it_test.go | 2 +- general_tests/a1_it_test.go | 8 +- general_tests/accounts_it_test.go | 2 +- general_tests/attributes_it_test.go | 6 +- general_tests/auth_test.go | 4 +- general_tests/cdrs_exp_it_test.go | 4 +- general_tests/cdrs_it_test.go | 20 +- general_tests/cdrs_onlexp_it_test.go | 16 +- general_tests/cdrs_post_failover_it_test.go | 4 +- general_tests/data_it_test.go | 12 +- general_tests/doubleremove_it_test.go | 2 +- general_tests/export_it_test.go | 8 +- general_tests/filters_it_test.go | 30 +- general_tests/gocs_it_test.go | 22 +- general_tests/oldtutorial_it_test.go | 40 +- general_tests/resourcesv1_it_test.go | 2 +- general_tests/route_it_test.go | 8 +- general_tests/rpccaching_it_test.go | 34 +- general_tests/rpcclient_it_test.go | 14 +- general_tests/session_it_test.go | 2 +- general_tests/sessionrefund_it_test.go | 4 +- general_tests/sessions_concur_test.go | 14 +- general_tests/smschrg1_test.go | 2 +- general_tests/suretax_it_test.go | 2 +- general_tests/tls_it_test.go | 8 +- general_tests/tp_it_test.go | 6 +- general_tests/tut_smgeneric_it_test.go | 1 - general_tests/tutorial_calls_test.go | 18 +- general_tests/twoengines_it_test.go | 6 +- guardian/guardian_test.go | 12 +- loaders/loader_test.go | 146 +++--- migrator/attributes_test.go | 10 +- migrator/cdrs_it_test.go | 2 +- migrator/rateprofiles_it_test.go | 8 +- migrator/session_costs_it_test.go | 2 +- migrator/stats_it_test.go | 28 +- migrator/stats_test.go | 20 +- migrator/thresholds_it_test.go | 12 +- migrator/thresholds_test.go | 4 +- rates/librates_test.go | 56 +-- scheduler/scheduler_test.go | 2 +- sessions/session_test.go | 168 +++---- sessions/sessions_bench_test.go | 2 +- sessions/sessions_birpc_it_test.go | 16 +- sessions/sessions_data_it_test.go | 12 +- sessions/sessions_it_test.go | 6 +- sessions/sessions_rpl_it_test.go | 34 +- sessions/sessions_voice_it_test.go | 68 +-- utils/apitpdata_test.go | 4 +- utils/cgrevent_test.go | 10 +- utils/chrgdincrement_test.go | 4 +- utils/coreutils.go | 2 +- utils/coreutils_test.go | 48 +- utils/dataconverter_test.go | 18 +- utils/reflect_test.go | 58 +-- utils/server.go | 8 +- 148 files changed, 1715 insertions(+), 1750 deletions(-) diff --git a/agents/agentreq_test.go b/agents/agentreq_test.go index d95fb62e7..66a4f97ce 100644 --- a/agents/agentreq_test.go +++ b/agents/agentreq_test.go @@ -52,13 +52,13 @@ func TestAgReqSetFields(t *testing.T) { agReq.CGRRequest.Set(&utils.FullPath{Path: utils.AnswerTime, PathItems: utils.PathItems{{Field: utils.AnswerTime}}}, utils.NewNMData( time.Date(2013, 12, 30, 15, 0, 1, 0, time.UTC))) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.RequestType, PathItems: utils.PathItems{{Field: utils.RequestType}}}, utils.NewNMData(utils.META_PREPAID)) - agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Usage, PathItems: utils.PathItems{{Field: utils.Usage}}}, utils.NewNMData(time.Duration(3*time.Minute))) + agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Usage, PathItems: utils.PathItems{{Field: utils.Usage}}}, utils.NewNMData(3*time.Minute)) cgrRply := utils.NavigableMap2{ utils.CapAttributes: utils.NavigableMap2{ "PaypalAccount": utils.NewNMData("cgrates@paypal.com"), }, - utils.CapMaxUsage: utils.NewNMData(time.Duration(120 * time.Second)), + utils.CapMaxUsage: utils.NewNMData(120 * time.Second), utils.Error: utils.NewNMData(""), } agReq.CGRReply = &cgrRply @@ -499,7 +499,7 @@ func TestAgReqMaxCost(t *testing.T) { agReq.CGRRequest.Set(&utils.FullPath{Path: utils.CapMaxUsage, PathItems: utils.PathItems{{Field: utils.CapMaxUsage}}}, utils.NewNMData("120s")) cgrRply := utils.NavigableMap2{ - utils.CapMaxUsage: utils.NewNMData(time.Duration(120 * time.Second)), + utils.CapMaxUsage: utils.NewNMData(120 * time.Second), } agReq.CGRReply = &cgrRply @@ -1013,7 +1013,7 @@ func TestAgReqNewARWithCGRRplyAndRply(t *testing.T) { utils.CapAttributes: utils.NavigableMap2{ "PaypalAccount": utils.NewNMData("cgrates@paypal.com"), }, - utils.CapMaxUsage: utils.NewNMData(time.Duration(120 * time.Second)), + utils.CapMaxUsage: utils.NewNMData(120 * time.Second), utils.Error: utils.NewNMData(""), } @@ -1107,7 +1107,7 @@ func TestAgReqSetCGRReplyWithoutError(t *testing.T) { utils.CapAttributes: utils.NavigableMap2{ "PaypalAccount": utils.NewNMData("cgrates@paypal.com"), }, - utils.CapMaxUsage: utils.NewNMData(time.Duration(120 * time.Second)), + utils.CapMaxUsage: utils.NewNMData(120 * time.Second), utils.Error: utils.NewNMData(""), } @@ -1218,7 +1218,7 @@ func TestAgReqParseFieldMetaCCUsage(t *testing.T) { } tplFlds[0].ComputePath() //5s*2 + 10s - expected := time.Duration(20 * time.Second) + expected := 20 * time.Second if out, err := agReq.ParseField(tplFlds[0]); err != nil { t.Error(err) } else if !reflect.DeepEqual(out, expected) { @@ -1734,13 +1734,13 @@ func TestAgReqSetFieldsWithRemove(t *testing.T) { agReq.CGRRequest.Set(&utils.FullPath{Path: utils.AnswerTime, PathItems: utils.PathItems{{Field: utils.AnswerTime}}}, utils.NewNMData( time.Date(2013, 12, 30, 15, 0, 1, 0, time.UTC))) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.RequestType, PathItems: utils.PathItems{{Field: utils.RequestType}}}, utils.NewNMData(utils.META_PREPAID)) - agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Usage, PathItems: utils.PathItems{{Field: utils.Usage}}}, utils.NewNMData(time.Duration(3*time.Minute))) + agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Usage, PathItems: utils.PathItems{{Field: utils.Usage}}}, utils.NewNMData(3*time.Minute)) agReq.CGRReply = &utils.NavigableMap2{ utils.CapAttributes: utils.NavigableMap2{ "PaypalAccount": utils.NewNMData("cgrates@paypal.com"), }, - utils.CapMaxUsage: utils.NewNMData(time.Duration(120 * time.Second)), + utils.CapMaxUsage: utils.NewNMData(120 * time.Second), utils.Error: utils.NewNMData(""), } @@ -1904,7 +1904,7 @@ func TestAgReqSetFieldsInCacheWithTimeOut(t *testing.T) { dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil) filterS := engine.NewFilterS(cfg, nil, dm) - cfg.CacheCfg().Partitions[utils.CacheUCH].TTL = 1 * time.Second + cfg.CacheCfg().Partitions[utils.CacheUCH].TTL = time.Second engine.Cache = engine.NewCacheS(cfg, dm) agReq := NewAgentRequest(nil, nil, nil, nil, nil, nil, "cgrates.org", "", filterS, nil, nil) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Account, PathItems: utils.PathItems{{Field: utils.Account}}}, utils.NewNMData("1001")) diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index dd847d657..24fc208fa 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -251,7 +251,7 @@ func testDiamItTPFromFolder(t *testing.T) { if isDispatcherActive { testDiamItTPLoadData(t) } - time.Sleep(time.Duration(1 * time.Second)) // Give time for scheduler to execute topups + time.Sleep(time.Second) // Give time for scheduler to execute topups } func testDiamItTPLoadData(t *testing.T) { @@ -972,7 +972,7 @@ func testDiamItCCRSMS(t *testing.T) { t.Error(err) } - time.Sleep(time.Duration(100) * time.Millisecond) + time.Sleep(100 * time.Millisecond) diamClnt.ReceivedMessage(rplyTimeout) var cdrs []*engine.CDR @@ -1051,7 +1051,7 @@ func testDiamItCCRMMS(t *testing.T) { t.Error(err) } - time.Sleep(time.Duration(100) * time.Millisecond) + time.Sleep(100 * time.Millisecond) diamClnt.ReceivedMessage(rplyTimeout) var cdrs []*engine.CDR @@ -1408,7 +1408,7 @@ func testDiamItTemplateErr(t *testing.T) { t.Error(err) } - time.Sleep(time.Duration(100) * time.Millisecond) + time.Sleep(100 * time.Millisecond) msg := diamClnt.ReceivedMessage(rplyTimeout) if msg == nil { diff --git a/agents/diamagent_test.go b/agents/diamagent_test.go index 5498fa79a..9b9189918 100644 --- a/agents/diamagent_test.go +++ b/agents/diamagent_test.go @@ -162,7 +162,7 @@ func TestProcessRequest(t *testing.T) { return nil } *prply = sessions.V1AuthorizeReply{ - MaxUsage: utils.DurationPointer(time.Duration(-1)), + MaxUsage: utils.DurationPointer(-1), } return nil }, diff --git a/agents/fsevent_test.go b/agents/fsevent_test.go index 844fa0e40..d930d49c7 100644 --- a/agents/fsevent_test.go +++ b/agents/fsevent_test.go @@ -374,7 +374,7 @@ func TestEventParseStatic(t *testing.T) { ev.GetDestination("^test") != "test" || setupTime != time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC) || answerTime != time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC) || - dur != time.Duration(60)*time.Second { + dur != 60*time.Second { t.Error("Values out of static not matching", ev.GetReqType("^test") != "test", ev.GetTenant("^test") != "test", @@ -384,7 +384,7 @@ func TestEventParseStatic(t *testing.T) { ev.GetDestination("^test") != "test", setupTime != time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), answerTime != time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), - dur != time.Duration(60)*time.Second) + dur != 60*time.Second) } } @@ -421,7 +421,7 @@ Task-Runtime: 1349437318` ev.GetDestination("FreeSWITCH-Hostname") != "h1.ip-switch.net" || setupTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC) || answerTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC) || - dur != time.Duration(65)*time.Second { + dur != 65*time.Second { t.Error("Values out of static not matching", ev.GetReqType("FreeSWITCH-Hostname") != "h1.ip-switch.net", ev.GetTenant("FreeSWITCH-Hostname") != "h1.ip-switch.net", @@ -431,7 +431,7 @@ Task-Runtime: 1349437318` ev.GetDestination("FreeSWITCH-Hostname") != "h1.ip-switch.net", setupTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC), answerTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC), - dur != time.Duration(65)*time.Second) + dur != 65*time.Second) } } @@ -473,7 +473,7 @@ func TestParseFsHangup(t *testing.T) { ev.GetDestination(utils.MetaDefault) != "1003" || setupTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC) || answerTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC) || - dur != time.Duration(66)*time.Second { + dur != 66*time.Second { t.Error("Default values not matching", ev.GetReqType(utils.MetaDefault) != utils.META_PREPAID, ev.GetTenant(utils.MetaDefault) != "cgrates.org", @@ -483,7 +483,7 @@ func TestParseFsHangup(t *testing.T) { ev.GetDestination(utils.MetaDefault) != "1003", setupTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC), answerTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC), - dur != time.Duration(66)*time.Second) + dur != 66*time.Second) } } @@ -589,13 +589,13 @@ func TestFsEvAsMapStringInterface(t *testing.T) { expectedMap[utils.AnswerTime] = aTime expectedMap[utils.RequestType] = utils.META_PREPAID expectedMap[utils.Destination] = "1003" - expectedMap[utils.Usage] = time.Duration(66) * time.Second + expectedMap[utils.Usage] = 66 * time.Second expectedMap[utils.Tenant] = "cgrates.org" expectedMap[utils.Account] = "1001" expectedMap[utils.Subject] = "1001" expectedMap[utils.Cost] = -1.0 - expectedMap[utils.PDD] = time.Duration(28) * time.Millisecond - expectedMap[utils.ACD] = time.Duration(30) * time.Second + expectedMap[utils.PDD] = 28 * time.Millisecond + expectedMap[utils.ACD] = 30 * time.Second expectedMap[utils.DISCONNECT_CAUSE] = "NORMAL_CLEARING" expectedMap[utils.ROUTE] = "supplier1" if storedMap := ev.AsMapStringInterface(""); !reflect.DeepEqual(expectedMap, storedMap) { diff --git a/agents/librad_test.go b/agents/librad_test.go index 84cb4dd6b..b566f9b19 100644 --- a/agents/librad_test.go +++ b/agents/librad_test.go @@ -90,7 +90,7 @@ func TestRadReplyAppendAttributes(t *testing.T) { v.ComputePath() } agReq := NewAgentRequest(nil, nil, nil, nil, nil, nil, "cgrates.org", "", nil, nil, nil) - agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapMaxUsage}), utils.NewNMData(time.Duration(time.Hour))) + agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapMaxUsage}), utils.NewNMData(time.Hour)) agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapAttributes, "RadReply"}), utils.NewNMData("AccessAccept")) agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapAttributes, utils.Account}), utils.NewNMData("1001")) diff --git a/agents/libsip_test.go b/agents/libsip_test.go index 3fa1881e8..756cd1ee5 100644 --- a/agents/libsip_test.go +++ b/agents/libsip_test.go @@ -42,7 +42,7 @@ func TestUpdateSIPMsgFromNavMap(t *testing.T) { v.ComputePath() } agReq := NewAgentRequest(nil, nil, nil, nil, nil, nil, "cgrates.org", "", nil, nil, nil) - agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapMaxUsage}), utils.NewNMData(time.Duration(time.Hour))) + agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapMaxUsage}), utils.NewNMData(time.Hour)) agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapAttributes, "Request"}), utils.NewNMData("SIP/2.0 302 Moved Temporarily")) agReq.CGRReply.Set(utils.NewPathItems([]string{utils.CapAttributes, utils.Account}), utils.NewNMData("1001")) @@ -66,7 +66,7 @@ func TestUpdateSIPMsgFromNavMap2(t *testing.T) { mv := utils.NewOrderedNavigableMap() var nm *config.NMItem mv.Set(&utils.FullPath{PathItems: utils.NewPathItems([]string{utils.CapAttributes, utils.Account}), Path: utils.CapAttributes + utils.NestingSep + utils.Account}, nm) - mv.Set(&utils.FullPath{PathItems: utils.NewPathItems([]string{utils.CapMaxUsage}), Path: utils.CapMaxUsage}, utils.NewNMData(time.Duration(time.Hour))) + mv.Set(&utils.FullPath{PathItems: utils.NewPathItems([]string{utils.CapMaxUsage}), Path: utils.CapMaxUsage}, utils.NewNMData(time.Hour)) expectedErr := `cannot encode reply value: [{"Field":"MaxUsage","Index":null}], err: not NMItems` if err := updateSIPMsgFromNavMap(m, mv); err == nil || err.Error() != expectedErr { diff --git a/apier/v1/apier2_it_test.go b/apier/v1/apier2_it_test.go index 9dff4975c..59cf1a2c8 100644 --- a/apier/v1/apier2_it_test.go +++ b/apier/v1/apier2_it_test.go @@ -248,7 +248,7 @@ func testAPIerGetRatingPlanCost(t *testing.T) { t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID) } else if *reply.EventCost.Cost != 6.5118 { t.Error("Unexpected Cost: ", *reply.EventCost.Cost) - } else if *reply.EventCost.Usage != time.Duration(time.Hour) { + } else if *reply.EventCost.Usage != time.Hour { t.Error("Unexpected Usage: ", *reply.EventCost.Usage) } } @@ -270,7 +270,7 @@ func testAPIerGetRatingPlanCost2(t *testing.T) { t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID) } else if *reply.EventCost.Cost != 36 { t.Error("Unexpected Cost: ", *reply.EventCost.Cost) - } else if *reply.EventCost.Usage != time.Duration(time.Hour) { + } else if *reply.EventCost.Usage != time.Hour { t.Error("Unexpected Usage: ", *reply.EventCost.Usage) } } @@ -289,7 +289,7 @@ func testAPIerGetRatingPlanCost3(t *testing.T) { t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID) } else if *reply.EventCost.Cost != 6.5118 { t.Error("Unexpected Cost: ", *reply.EventCost.Cost) - } else if *reply.EventCost.Usage != time.Duration(time.Hour) { + } else if *reply.EventCost.Usage != time.Hour { t.Error("Unexpected Usage: ", *reply.EventCost.Usage) } } @@ -410,7 +410,7 @@ func testAPIerSetActionPlanDfltTime(t *testing.T) { } case "AP_HOURLY": if schedAct.NextRunTime.Before(time.Now().Add(59*time.Minute+58*time.Second)) || - schedAct.NextRunTime.After(time.Now().Add(1*time.Hour+1*time.Second)) { + schedAct.NextRunTime.After(time.Now().Add(time.Hour+time.Second)) { t.Errorf("Expected the nextRuntime to be after 1 hour,but received: <%+v>", utils.ToJSON(schedAct)) } case "AP_MONTHLY": @@ -419,8 +419,8 @@ func testAPIerSetActionPlanDfltTime(t *testing.T) { expected := tnow.AddDate(0, 1, 0) expected = time.Date(expected.Year(), expected.Month(), tnow.Day(), tnow.Hour(), tnow.Minute(), tnow.Second(), 0, schedAct.NextRunTime.Location()) - if schedAct.NextRunTime.Before(expected.Add(-1*time.Second)) || - schedAct.NextRunTime.After(expected.Add(1*time.Second)) { + if schedAct.NextRunTime.Before(expected.Add(-time.Second)) || + schedAct.NextRunTime.After(expected.Add(time.Second)) { t.Errorf("Expected the nextRuntime to be after 1 month,but received: <%+v>", utils.ToJSON(schedAct)) } } diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index 9c1ed8345..718a66973 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -1066,7 +1066,7 @@ func testApierGetRatingPlan(t *testing.T) { t.Error("Unexpected number of items received") } riRate := &engine.RIRate{ConnectFee: 0, RoundingMethod: "*up", RoundingDecimals: 2, Rates: []*engine.RGRate{ - {GroupIntervalStart: 0, Value: 0, RateIncrement: time.Duration(60) * time.Second, RateUnit: time.Duration(60) * time.Second}, + {GroupIntervalStart: 0, Value: 0, RateIncrement: 60 * time.Second, RateUnit: 60 * time.Second}, }} for _, rating := range reply.Ratings { riRateJson, _ := json.Marshal(rating) @@ -1575,7 +1575,7 @@ func testApierResetDataAfterLoadFromFolder(t *testing.T) { time.Sleep(10 * time.Millisecond) var rcvStats map[string]*ltcache.CacheStats expStats := engine.GetDefaultEmptyCacheStats() - expStats[utils.CacheAccountActionPlans].Items = 13 + expStats[utils.CacheAccountActionPlans].Items = 3 expStats[utils.CacheActionPlans].Items = 7 expStats[utils.CacheActions].Items = 5 expStats[utils.CacheDestinations].Items = 3 @@ -1695,7 +1695,7 @@ func testApierMaxDebitInexistentAcnt(t *testing.T) { Account: "INVALID", Destination: "1002", TimeStart: time.Date(2014, 3, 27, 10, 42, 26, 0, time.UTC), - TimeEnd: time.Date(2014, 3, 27, 10, 42, 26, 0, time.UTC).Add(time.Duration(10) * time.Second), + TimeEnd: time.Date(2014, 3, 27, 10, 42, 26, 0, time.UTC).Add(10 * time.Second), }, } if err := rater.Call(utils.ResponderMaxDebit, cd, cc); err == nil { @@ -1742,7 +1742,7 @@ func testApierITProcessCdr(t *testing.T) { OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, } if err := rater.Call(utils.CDRsV1ProcessCDR, cdr, &reply); err != nil { @@ -1790,7 +1790,7 @@ func testApierGetCallCostLog(t *testing.T) { SetupTime: tm, AnswerTime: tm, RunID: utils.MetaDefault, - Usage: time.Duration(0), + Usage: 0, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, @@ -2146,7 +2146,7 @@ func testApierReplayFldPosts(t *testing.T) { if rcvCDR[utils.CGRID] != "88ed9c38005f07576a1e1af293063833b60edcc6" { t.Errorf("Unexpected CDR received: %+v", rcvCDR) } - case <-time.After(time.Duration(100 * time.Millisecond)): + case <-time.After(100 * time.Millisecond): t.Error("No message received from RabbitMQ") } for _, dir := range []string{*args.FailedRequestsInDir, *args.FailedRequestsOutDir} { diff --git a/apier/v1/caches_it_test.go b/apier/v1/caches_it_test.go index f3f72309f..7e8b2be49 100644 --- a/apier/v1/caches_it_test.go +++ b/apier/v1/caches_it_test.go @@ -129,7 +129,7 @@ func testCacheSLoadTariffPlanFromFolder(t *testing.T) { func testCacheSAfterLoadFromFolder(t *testing.T) { var rcvStats map[string]*ltcache.CacheStats expStats := engine.GetDefaultEmptyCacheStats() - expStats[utils.CacheAccountActionPlans].Items = 13 + expStats[utils.CacheAccountActionPlans].Items = 3 expStats[utils.CacheActionPlans].Items = 7 expStats[utils.CacheActions].Items = 5 expStats[utils.CacheDestinations].Items = 3 @@ -211,7 +211,7 @@ func testCacheSReload(t *testing.T) { } else if reply != utils.OK { t.Error(reply) } - expStats[utils.CacheAccountActionPlans].Items = 13 + expStats[utils.CacheAccountActionPlans].Items = 3 expStats[utils.CacheActionPlans].Items = 7 expStats[utils.CacheActions].Items = 6 expStats[utils.CacheDestinations].Items = 3 diff --git a/apier/v1/cdrs_it_test.go b/apier/v1/cdrs_it_test.go index 0a4de2b2a..764a0d1b6 100644 --- a/apier/v1/cdrs_it_test.go +++ b/apier/v1/cdrs_it_test.go @@ -178,7 +178,7 @@ func testV1CDRsProcessEventWithRefund(t *testing.T) { utils.Account: "testV1CDRsProcessEventWithRefund", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: time.Duration(3) * time.Minute, + utils.Usage: 3 * time.Minute, }, }, }, @@ -228,7 +228,7 @@ func testV1CDRsProcessEventWithRefund(t *testing.T) { utils.Account: "testV1CDRsProcessEventWithRefund", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, }, }, }, @@ -285,25 +285,25 @@ func testV1CDRsRefundOutOfSessionCost(t *testing.T) { RunID: utils.MetaDefault, OriginID: "testV1CDRsRefundOutOfSessionCost", CostSource: utils.MetaSessionS, - Usage: time.Duration(3 * time.Minute), + Usage: 3 * time.Minute, CostDetails: &engine.EventCost{ CGRID: "test1", RunID: utils.MetaDefault, StartTime: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), - Usage: utils.DurationPointer(time.Duration(3 * time.Minute)), + Usage: utils.DurationPointer(3 * time.Minute), Cost: utils.Float64Pointer(2.3), Charges: []*engine.ChargingInterval{ { RatingID: "c1a5ab9", Increments: []*engine.ChargingIncrement{ { - Usage: time.Duration(2 * time.Minute), + Usage: 2 * time.Minute, Cost: 2.0, AccountingID: "a012888", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 60, @@ -349,10 +349,10 @@ func testV1CDRsRefundOutOfSessionCost(t *testing.T) { Rates: engine.ChargedRates{ "ec1a177": engine.RateGroups{ &engine.RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, }, }, @@ -378,7 +378,7 @@ func testV1CDRsRefundOutOfSessionCost(t *testing.T) { utils.Account: "testV1CDRsRefundOutOfSessionCost", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: time.Duration(123) * time.Minute, + utils.Usage: 123 * time.Minute, }, }, }, @@ -443,25 +443,25 @@ func testV1CDRsRefundCDR(t *testing.T) { utils.Account: "testV1CDRsRefundCDR", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Minute, + utils.Usage: 10 * time.Minute, utils.CostDetails: &engine.EventCost{ CGRID: "test1", RunID: utils.MetaDefault, StartTime: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), - Usage: utils.DurationPointer(time.Duration(3 * time.Minute)), + Usage: utils.DurationPointer(3 * time.Minute), Cost: utils.Float64Pointer(2.3), Charges: []*engine.ChargingInterval{ { RatingID: "c1a5ab9", Increments: []*engine.ChargingIncrement{ { - Usage: time.Duration(2 * time.Minute), + Usage: 2 * time.Minute, Cost: 2.0, AccountingID: "a012888", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 60, @@ -507,10 +507,10 @@ func testV1CDRsRefundCDR(t *testing.T) { Rates: engine.ChargedRates{ "ec1a177": engine.RateGroups{ &engine.RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, }, }, @@ -603,7 +603,7 @@ func testV1CDRsAddBalanceForSMS(t *testing.T) { utils.Account: "testV1CDRsAddBalanceForSMS", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: time.Duration(1), + utils.Usage: 1, }, }, }, diff --git a/apier/v1/concreqs_it_test.go b/apier/v1/concreqs_it_test.go index bd4332e6e..5acdb1986 100644 --- a/apier/v1/concreqs_it_test.go +++ b/apier/v1/concreqs_it_test.go @@ -126,7 +126,7 @@ func testConcReqsBusyAPIs(t *testing.T) { go func() { var resp string if err := concReqsRPC.Call(utils.CoreSv1Sleep, - &utils.DurationArgs{DurationTime: time.Duration(10 * time.Millisecond)}, + &utils.DurationArgs{DurationTime: 10 * time.Millisecond}, &resp); err != nil { lock.Lock() failedAPIs++ @@ -153,7 +153,7 @@ func testConcReqsQueueAPIs(t *testing.T) { go func() { var resp string if err := concReqsRPC.Call(utils.CoreSv1Sleep, - &utils.DurationArgs{DurationTime: time.Duration(10 * time.Millisecond)}, + &utils.DurationArgs{DurationTime: 10 * time.Millisecond}, &resp); err != nil { wg.Done() t.Error(err) @@ -236,7 +236,7 @@ func testConcReqsOnBiJSONBusy(t *testing.T) { go func() { var resp string if err := concReqsBiRPC.Call(utils.SessionSv1Sleep, - &utils.DurationArgs{DurationTime: time.Duration(10 * time.Millisecond)}, + &utils.DurationArgs{DurationTime: 10 * time.Millisecond}, &resp); err != nil { lock.Lock() failedAPIs++ @@ -263,7 +263,7 @@ func testConcReqsOnBiJSONQueue(t *testing.T) { go func() { var resp string if err := concReqsBiRPC.Call(utils.SessionSv1Sleep, - &utils.DurationArgs{DurationTime: time.Duration(10 * time.Millisecond)}, + &utils.DurationArgs{DurationTime: 10 * time.Millisecond}, &resp); err != nil { wg.Done() t.Error(err) diff --git a/apier/v1/config_it_test.go b/apier/v1/config_it_test.go index dd183f023..9b79b12a6 100644 --- a/apier/v1/config_it_test.go +++ b/apier/v1/config_it_test.go @@ -330,7 +330,7 @@ func testConfigStartEngineFromHTTP(t *testing.T) { if !connected { t.Errorf("engine did not open port <%s>", "localhost:2012") } - time.Sleep(time.Duration(500) * time.Millisecond) + time.Sleep(500 * time.Millisecond) var rply map[string]interface{} if err := jsonClnt.Call(utils.CoreSv1Status, &utils.TenantWithOpts{}, &rply); err != nil { t.Error(err) diff --git a/apier/v1/ees_it_test.go b/apier/v1/ees_it_test.go index 4345ad2e2..370c06c6f 100644 --- a/apier/v1/ees_it_test.go +++ b/apier/v1/ees_it_test.go @@ -145,28 +145,28 @@ func testEEsAddCDRs(t *testing.T) { OrderID: 1, ToR: utils.VOICE, OriginID: "OriginCDR1", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_NONE, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), - AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: time.Duration(10) * time.Second, + AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, {CGRID: "Cdr2", OrderID: 2, ToR: utils.VOICE, OriginID: "OriginCDR2", OriginHost: "192.168.1.1", Source: "test2", RequestType: utils.META_NONE, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), - AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: time.Duration(5) * time.Second, + AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: 5 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, {CGRID: "Cdr3", OrderID: 3, ToR: utils.VOICE, OriginID: "OriginCDR3", OriginHost: "192.168.1.1", Source: "test2", RequestType: utils.META_NONE, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), - AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: time.Duration(30) * time.Second, + AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: 30 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, {CGRID: "Cdr4", OrderID: 4, ToR: utils.VOICE, OriginID: "OriginCDR4", OriginHost: "192.168.1.1", Source: "test3", RequestType: utils.META_NONE, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), - AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: time.Duration(0) * time.Second, + AnswerTime: time.Date(2018, 10, 4, 15, 3, 10, 0, time.UTC), RunID: utils.MetaDefault, Usage: 0, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, } diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index 9beb3408b..7194eceda 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -189,7 +189,7 @@ func testV1FIdxSetThresholdProfile(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: 1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1", "ACT_2"}, @@ -285,7 +285,7 @@ func testV1FIdxSetSecondThresholdProfile(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: 1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1", "ACT_2"}, @@ -449,7 +449,7 @@ func testV1FIdxSetStatQueueProfileIndexes(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaSum, @@ -552,7 +552,7 @@ func testV1FIdxSetSecondStatQueueProfileIndexes(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: "*sum", @@ -696,7 +696,7 @@ func testV1FIdxSetResourceProfileIndexes(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(10) * time.Microsecond, + UsageTTL: 10 * time.Microsecond, Limit: 10, AllocationMessage: "MessageAllocation", Blocker: true, @@ -789,7 +789,7 @@ func testV1FIdxSetSecondResourceProfileIndexes(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(10) * time.Microsecond, + UsageTTL: 10 * time.Microsecond, Limit: 10, AllocationMessage: "MessageAllocation", Blocker: true, diff --git a/apier/v1/filterindexecache_it_test.go b/apier/v1/filterindexecache_it_test.go index 41d310997..88d1779a6 100644 --- a/apier/v1/filterindexecache_it_test.go +++ b/apier/v1/filterindexecache_it_test.go @@ -202,7 +202,7 @@ func testV1FIdxCaSetThresholdProfile(t *testing.T) { }, MinHits: 1, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, Async: true, @@ -310,7 +310,7 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, Async: true, @@ -614,7 +614,7 @@ func testV1FIdxCaSetStatQueueProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: "*sum#~*req.Val", @@ -670,7 +670,7 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.Cost: 12.1, }, }, @@ -689,7 +689,7 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.Cost: 12.1, }, }, @@ -710,7 +710,7 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { utils.EventType: utils.AccountUpdate, utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.Cost: 12.1, }, }, @@ -733,7 +733,7 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { utils.EventType: utils.AccountUpdate, utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.Cost: 12.1, }, }, @@ -786,7 +786,7 @@ func testV1FIdxCaUpdateStatQueueProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: "*sum#~*req.Val", @@ -879,7 +879,7 @@ func testV1FIdxCaUpdateStatQueueProfileFromTP(t *testing.T) { utils.EventType: utils.AccountUpdate, utils.Account: "1003", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.Cost: 12.1, }, }, @@ -932,7 +932,7 @@ func testV1FIdxCaRemoveStatQueueProfile(t *testing.T) { utils.EventType: utils.AccountUpdate, utils.Account: "1003", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.Cost: 12.1, }, }, @@ -1392,7 +1392,7 @@ func testV1FIdxCaSetResourceProfile(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(0) * time.Microsecond, + UsageTTL: 0, AllocationMessage: "Approved", Limit: 10, Blocker: true, @@ -1527,7 +1527,7 @@ func testV1FIdxCaUpdateResourceProfile(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(10) * time.Microsecond, + UsageTTL: 10 * time.Microsecond, Limit: 10, AllocationMessage: "MessageAllocation", Blocker: true, diff --git a/apier/v1/precache_it_test.go b/apier/v1/precache_it_test.go index 52459f7e4..9c3fb741e 100644 --- a/apier/v1/precache_it_test.go +++ b/apier/v1/precache_it_test.go @@ -155,97 +155,78 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) { CacheIDs: []string{}, } expectedStats := &map[string]*ltcache.CacheStats{ - utils.MetaDefault: {}, - utils.CacheAccountActionPlans: { - Items: 5, - Groups: 0, - }, + utils.MetaDefault: {}, + utils.CacheAccountActionPlans: {}, utils.CacheActionPlans: { - Items: 4, - Groups: 0, + Items: 4, }, utils.CacheActionTriggers: { - Items: 1, - Groups: 0, + Items: 1, }, utils.CacheActions: { - Items: 9, - Groups: 0, + Items: 9, }, utils.CacheAttributeFilterIndexes: { Items: 2, Groups: 2, }, utils.CacheAttributeProfiles: { - Items: 1, - Groups: 0, + Items: 1, }, utils.CacheChargerFilterIndexes: {}, utils.CacheChargerProfiles: {}, utils.CacheDispatcherFilterIndexes: {}, utils.CacheDispatcherProfiles: { - Items: 6, - Groups: 0, + Items: 6, }, utils.CacheDispatcherHosts: { - Items: 1, - Groups: 0, + Items: 1, }, utils.CacheDispatcherRoutes: {}, utils.CacheDispatcherLoads: {}, utils.CacheDestinations: { - Items: 5, - Groups: 0, + Items: 5, }, utils.CacheDispatchers: {}, utils.CacheEventResources: {}, utils.CacheFilters: { - Items: 15, - Groups: 0, + Items: 15, }, utils.CacheRateProfilesFilterIndexes: {}, utils.CacheRateFilterIndexes: {}, utils.CacheRateProfiles: {}, utils.CacheRatingPlans: { - Items: 4, - Groups: 0, + Items: 4, }, utils.CacheRatingProfiles: { - Items: 5, - Groups: 0, + Items: 5, }, utils.CacheResourceFilterIndexes: { Items: 6, Groups: 1, }, utils.CacheResourceProfiles: { - Items: 3, - Groups: 0, + Items: 3, }, utils.CacheResources: { - Items: 3, - Groups: 0, + Items: 3, }, utils.CacheReverseDestinations: { - Items: 7, - Groups: 0, + Items: 7, }, utils.CacheRPCResponses: {}, utils.CacheSharedGroups: { - Items: 1, - Groups: 0, + Items: 1, }, utils.CacheStatFilterIndexes: { Items: 2, Groups: 1, }, utils.CacheStatQueueProfiles: { - Items: 1, - Groups: 0, + Items: 1, }, utils.CacheStatQueues: { - Items: 1, - Groups: 0, + Items: 1, }, utils.CacheSTIR: {}, utils.CacheEventCharges: {}, @@ -254,20 +235,17 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) { Groups: 1, }, utils.CacheRouteProfiles: { - Items: 3, - Groups: 0, + Items: 3, }, utils.CacheThresholdFilterIndexes: { Items: 10, Groups: 1, }, utils.CacheThresholdProfiles: { - Items: 7, - Groups: 0, + Items: 7, }, utils.CacheThresholds: { - Items: 7, - Groups: 0, + Items: 7, }, utils.CacheTimings: {}, utils.CacheDiameterMessages: {}, diff --git a/apier/v1/preload_it_test.go b/apier/v1/preload_it_test.go index d04b12985..b3112afae 100644 --- a/apier/v1/preload_it_test.go +++ b/apier/v1/preload_it_test.go @@ -110,7 +110,7 @@ func testPreloadITStartEngine(t *testing.T) { if !connected { t.Errorf("engine did not open port <%s>", preloadCfg.ListenCfg().RPCJSONListen) } - time.Sleep(time.Duration(500) * time.Millisecond) + time.Sleep(500 * time.Millisecond) } func testPreloadITRpcConn(t *testing.T) { diff --git a/apier/v1/rateprofiles_it_test.go b/apier/v1/rateprofiles_it_test.go index eeb1d077b..b9f7bd2d1 100644 --- a/apier/v1/rateprofiles_it_test.go +++ b/apier/v1/rateprofiles_it_test.go @@ -158,16 +158,16 @@ func testV1RatePrfVerifyRateProfile(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -177,10 +177,10 @@ func testV1RatePrfVerifyRateProfile(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -190,10 +190,10 @@ func testV1RatePrfVerifyRateProfile(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -234,10 +234,10 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, }, }, @@ -273,16 +273,16 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -292,10 +292,10 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -305,10 +305,10 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -354,16 +354,16 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -373,10 +373,10 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -386,10 +386,10 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -424,16 +424,16 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -443,10 +443,10 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -456,10 +456,10 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -505,16 +505,16 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -524,10 +524,10 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -608,10 +608,10 @@ func testV1RateGetRemoveRateProfileWithoutTenant(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, }, }, @@ -706,16 +706,16 @@ func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -725,10 +725,10 @@ func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -738,10 +738,10 @@ func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index cc41c787a..f7b3d2aba 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -68,7 +68,7 @@ var ( testInternalRemoteITGetRatingProfile, testInternalRemoteITGetAction, testInternalRemoteITGetActionPlan, - testInternalRemoteITGetAccountActionPlan, + // testInternalRemoteITGetAccountActionPlan, testInternalRemoteITGetDestination, testInternalRemoteITGetReverseDestination, testInternalRemoteITGetChargerProfile, @@ -290,7 +290,7 @@ func testInternalRemoteITGetThresholdProfile(t *testing.T) { }, MaxHits: 1, MinHits: 1, - MinSleep: time.Duration(1 * time.Second), + MinSleep: time.Second, Weight: 10.0, ActionIDs: []string{"ACT_LOG_WARNING"}, Async: true, @@ -335,7 +335,7 @@ func testInternalRemoteITGetResourceProfile(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, - UsageTTL: time.Duration(-1), + UsageTTL: -1, Limit: 7, AllocationMessage: "", Stored: true, @@ -541,11 +541,7 @@ func testInternalRemoteITGetAction(t *testing.T) { func testInternalRemoteITGetActionPlan(t *testing.T) { var aps []*engine.ActionPlan - accIDsStrMp := utils.StringMap{ - "cgrates.org:1001": true, - "cgrates.org:1002": true, - "cgrates.org:1003": true, - } + accIDsStrMp := utils.StringMap{} if err := internalRPC.Call(utils.APIerSv1GetActionPlan, &AttrGetActionPlan{ID: "AP_PACKAGE_10"}, &aps); err != nil { t.Error(err) @@ -736,16 +732,16 @@ func testInternalRemoteITGetRouteProfile(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -755,10 +751,10 @@ func testInternalRemoteITGetRouteProfile(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -768,10 +764,10 @@ func testInternalRemoteITGetRouteProfile(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -840,7 +836,7 @@ func testInternalReplicationSetThreshold(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_LOG_WARNING"}, @@ -1145,7 +1141,7 @@ func testInternalReplicateStats(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaACD, diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index c825d5635..108259b98 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -438,7 +438,7 @@ func testInternalReplicateITStatQueueProfile(t *testing.T) { ExpiryTime: time.Date(2020, 4, 18, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: "*sum", @@ -784,7 +784,7 @@ func testInternalReplicateITResourceProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1) * time.Nanosecond, + UsageTTL: time.Nanosecond, Limit: 10, AllocationMessage: "MessageAllocation", Blocker: true, @@ -1026,7 +1026,7 @@ func testInternalReplicateITThresholdProfile(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: 1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1", "ACT_2"}, @@ -1373,16 +1373,16 @@ func testInternalReplicateITRateProfile(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1392,10 +1392,10 @@ func testInternalReplicateITRateProfile(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1405,10 +1405,10 @@ func testInternalReplicateITRateProfile(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, diff --git a/apier/v1/resourcesv1_it_test.go b/apier/v1/resourcesv1_it_test.go index 583ae99a1..c7f6a28f4 100644 --- a/apier/v1/resourcesv1_it_test.go +++ b/apier/v1/resourcesv1_it_test.go @@ -714,7 +714,7 @@ func testV1RsSetResourceProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1) * time.Nanosecond, + UsageTTL: time.Nanosecond, Limit: 10, AllocationMessage: "MessageAllocation", Blocker: true, @@ -826,7 +826,7 @@ func testV1RsMatchNotFound(t *testing.T) { Tenant: "cgrates.org", ID: "Res_NotFound", FilterIDs: []string{"*string:~*req.Account:CustomTest", "*notempty:~*req.Custom:"}, - UsageTTL: time.Duration(1) * time.Nanosecond, + UsageTTL: time.Nanosecond, Limit: 10, AllocationMessage: "MessageAllocation", Stored: true, @@ -872,7 +872,7 @@ func testV1RsAllocateUnlimited(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(-1), + UsageTTL: -1, Limit: -1, AllocationMessage: "CustomUnlimitedMessage", Stored: true, @@ -944,7 +944,7 @@ func testV1RsGetResourceProfileWithoutTenant(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1) * time.Nanosecond, + UsageTTL: time.Nanosecond, Limit: 10, AllocationMessage: "MessageAllocation", Blocker: true, diff --git a/apier/v1/routes_it_test.go b/apier/v1/routes_it_test.go index ebecf9bff..616e15762 100644 --- a/apier/v1/routes_it_test.go +++ b/apier/v1/routes_it_test.go @@ -534,7 +534,7 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 10.0, }, }, @@ -555,7 +555,7 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 10.5, }, }, @@ -576,7 +576,7 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(5 * time.Second), + utils.Usage: 5 * time.Second, utils.COST: 12.5, }, }, @@ -597,7 +597,7 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(6 * time.Second), + utils.Usage: 6 * time.Second, utils.COST: 17.5, }, }, @@ -618,7 +618,7 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1003", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 12.5, }, }, @@ -639,9 +639,9 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { Event: map[string]interface{}{ "Stat": "Stat1_1", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 12.5, - utils.PDD: time.Duration(12 * time.Second), + utils.PDD: 12 * time.Second, }, }, }, @@ -661,9 +661,9 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { Event: map[string]interface{}{ "Stat": "Stat1_1", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(15 * time.Second), + utils.Usage: 15 * time.Second, utils.COST: 15.5, - utils.PDD: time.Duration(15 * time.Second), + utils.PDD: 15 * time.Second, }, }, }, diff --git a/apier/v1/sessions_thresholds_it_test.go b/apier/v1/sessions_thresholds_it_test.go index 841cb4293..c151172c2 100755 --- a/apier/v1/sessions_thresholds_it_test.go +++ b/apier/v1/sessions_thresholds_it_test.go @@ -156,7 +156,7 @@ func testSessionSv1ItGetThreshold(t *testing.T) { ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(0), + MinSleep: 0, Blocker: false, Weight: 10.0, ActionIDs: []string{"TOPUP_MONETARY_10"}, @@ -454,9 +454,9 @@ func testSessionSv1ItInitNotFoundThreshold(t *testing.T) { args, &rply); err != nil { t.Error(err) } - if rply.MaxUsage == nil || *rply.MaxUsage != time.Duration(1024) { + if rply.MaxUsage == nil || *rply.MaxUsage != 1024 { t.Errorf("Expecting: %+v, received: %+v", - time.Duration(1024), rply.MaxUsage) + 1024, rply.MaxUsage) } if rply.ThresholdIDs != nil { t.Errorf("Expecting: nil, received: %s", @@ -593,9 +593,9 @@ func testSessionSv1ItInitNotFoundThresholdAndStats(t *testing.T) { args, &rply); err != nil { t.Error(err) } - if rply.MaxUsage == nil || *rply.MaxUsage != time.Duration(1024) { + if rply.MaxUsage == nil || *rply.MaxUsage != 1024 { t.Errorf("Expecting: %+v, received: %+v", - time.Duration(1024), rply.MaxUsage) + 1024, rply.MaxUsage) } if rply.ThresholdIDs != nil { t.Errorf("Expecting: nil, received: %s", diff --git a/apier/v1/sessionsv1_it_test.go b/apier/v1/sessionsv1_it_test.go index 940e2bafa..a098913be 100644 --- a/apier/v1/sessionsv1_it_test.go +++ b/apier/v1/sessionsv1_it_test.go @@ -410,7 +410,7 @@ func testSSv1ItInitiateSession(t *testing.T) { } func testSSv1ItInitiateSessionWithDigest(t *testing.T) { - initUsage := time.Duration(5 * time.Minute) + initUsage := 5 * time.Minute args := &sessions.V1InitSessionArgs{ InitSession: true, AllocateResources: true, diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index 67edc9b18..6b1f3ee95 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -47,7 +47,7 @@ var ( Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(135 * time.Second), + utils.Usage: 135 * time.Second, utils.COST: 123.0}}, { Tenant: "cgrates.org", @@ -55,7 +55,7 @@ var ( Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second)}}, + utils.Usage: 45 * time.Second}}, { Tenant: "cgrates.org", ID: "event3", @@ -224,9 +224,9 @@ func testV1STSProcessEvent(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(135 * time.Second), + utils.Usage: 135 * time.Second, utils.COST: 123.0, - utils.PDD: time.Duration(12 * time.Second), + utils.PDD: 12 * time.Second, }, }, }, @@ -282,7 +282,7 @@ func testV1STSProcessEvent(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.Cost: 12.1, }, }, @@ -405,7 +405,7 @@ func testV1STSSetStatQueueProfile(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaACD, @@ -556,7 +556,7 @@ func testV1STSProcessMetricsWithFilter(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1) * time.Second, + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaACD, @@ -617,7 +617,7 @@ func testV1STSProcessMetricsWithFilter(t *testing.T) { ID: "event1", Event: map[string]interface{}{ "DistinctVal": "RandomVal", - utils.Usage: time.Duration(6 * time.Second), + utils.Usage: 6 * time.Second, "CustomValue": 7.0, }, }, @@ -649,7 +649,7 @@ func testV1STSProcessMetricsWithFilter(t *testing.T) { ID: "event2", Event: map[string]interface{}{ "DistinctVal": "RandomVal", - utils.Usage: time.Duration(12 * time.Second), + utils.Usage: 12 * time.Second, "CustomValue": 10.0, }, }, @@ -791,7 +791,7 @@ func testV1STSProcessStatWithThreshold(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1) * time.Second, + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaTCD, @@ -821,7 +821,7 @@ func testV1STSProcessStatWithThreshold(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Weight: 20.0, ActionIDs: []string{"LOG_WARNING"}, Async: true, @@ -842,7 +842,7 @@ func testV1STSProcessStatWithThreshold(t *testing.T) { ID: "event1", Event: map[string]interface{}{ "CustomEvent": "CustomEvent", - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, }, }, }, @@ -873,7 +873,7 @@ func testV1STSProcessCDRStat(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1) * time.Second, + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaSum + utils.HashtagSep + "~*req.CostDetails.Usage", @@ -951,13 +951,13 @@ func testV1STSProcessCDRStat(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, CostDetails: engine.NewEventCostFromCallCost(cc, "TestCDRTestCDRAsMapStringIface2", utils.MetaDefault), } cdr.CostDetails.Compute() - cdr.CostDetails.Usage = utils.DurationPointer(time.Duration(10) * time.Second) + cdr.CostDetails.Usage = utils.DurationPointer(10 * time.Second) var reply2 []string expected := []string{"StatForCDR"} @@ -1010,7 +1010,7 @@ func testV1STSOverWriteStats(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1) * time.Second, + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaSum + utils.HashtagSep + "1", @@ -1060,7 +1060,7 @@ func testV1STSOverWriteStats(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1) * time.Second, + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaSum + utils.HashtagSep + "~*req.Test", @@ -1102,7 +1102,7 @@ func testV1STSProcessStatWithThreshold2(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1) * time.Second, + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaTCD, @@ -1132,7 +1132,7 @@ func testV1STSProcessStatWithThreshold2(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Weight: 20.0, ActionIDs: []string{"LOG_WARNING"}, Async: true, @@ -1153,7 +1153,7 @@ func testV1STSProcessStatWithThreshold2(t *testing.T) { ID: "event1", Event: map[string]interface{}{ "CustomEvent2": "CustomEvent2", - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, }, }, }, @@ -1226,7 +1226,7 @@ func testV1STSGetStatQueueProfileWithoutTenant(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaACD, @@ -1313,7 +1313,7 @@ func testV1STSV1GetStatQueuesForEventWithoutTenant(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.RunID: utils.MetaDefault, utils.COST: 10.0, utils.Destination: "1001", @@ -1343,7 +1343,7 @@ func testV1STSSimulateAccountUpdate(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1) * time.Second, + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaSum + utils.HashtagSep + "~*asm.BalanceSummaries.HolidayBalance.Value", diff --git a/apier/v1/thresholds_it_test.go b/apier/v1/thresholds_it_test.go index b60dc369d..8ec654b3d 100644 --- a/apier/v1/thresholds_it_test.go +++ b/apier/v1/thresholds_it_test.go @@ -207,9 +207,9 @@ var ( utils.Subject: "1007", utils.Destination: "+4986517174963", utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), - utils.PDD: time.Duration(0) * time.Second, + utils.PDD: 0 * time.Second, utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.ROUTE: "SUPPL1", utils.COST: -1.0, }, @@ -448,7 +448,7 @@ func testV1TSSetThresholdProfileBrokenReference(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1"}, @@ -499,7 +499,7 @@ func testV1TSSetThresholdProfile(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1"}, @@ -767,7 +767,7 @@ func testV1TSGetThresholdProfileWithoutTenant(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1"}, @@ -879,7 +879,7 @@ func testV1TSProcessAccountUpdateEvent(t *testing.T) { "*gt:~*asm.BalanceSummaries.HolidayBalance.Value:1.0", }, MaxHits: 10, - MinSleep: time.Duration(10 * time.Millisecond), + MinSleep: 10 * time.Millisecond, Weight: 20.0, ActionIDs: []string{"LOG_WARNING"}, Async: true, diff --git a/apier/v1/tpaccountactions_it_test.go b/apier/v1/tpaccountactions_it_test.go index 61058dbc9..36786ac57 100644 --- a/apier/v1/tpaccountactions_it_test.go +++ b/apier/v1/tpaccountactions_it_test.go @@ -215,7 +215,7 @@ func testTPAccActionsRemTPAccAction(t *testing.T) { } else if resp != utils.OK { t.Error("Unexpected reply returned", resp) } - time.Sleep(time.Duration(100 * time.Millisecond)) + time.Sleep(100 * time.Millisecond) } func testTPAccActionsGetTPAccActionAfterRemove(t *testing.T) { diff --git a/apier/v1/tpratingprofiles_it_test.go b/apier/v1/tpratingprofiles_it_test.go index 96a511141..fdf10b65e 100644 --- a/apier/v1/tpratingprofiles_it_test.go +++ b/apier/v1/tpratingprofiles_it_test.go @@ -272,7 +272,7 @@ func testTPRatingProfilesRemoveTPRatingProfile(t *testing.T) { } else if resp != utils.OK { t.Error("Unexpected reply returned", resp) } - time.Sleep(time.Duration(100 * time.Millisecond)) + time.Sleep(100 * time.Millisecond) } func testTPRatingProfilesGetTPRatingProfileAfterRemove(t *testing.T) { diff --git a/apier/v2/apierv2_it_test.go b/apier/v2/apierv2_it_test.go index 749504b43..cdff5e60a 100644 --- a/apier/v2/apierv2_it_test.go +++ b/apier/v2/apierv2_it_test.go @@ -256,7 +256,7 @@ func testAPIerSv2itSetAccountWithAP(t *testing.T) { if err := apierRPC.Call(utils.APIerSv2SetActions, &argActs1, &reply); err != nil { t.Error(err) } - tNow := time.Now().Add(time.Duration(time.Minute)) + tNow := time.Now().Add(time.Minute) argAP1 := &v1.AttrSetActionPlan{Id: "TestAPIerSv2itSetAccountWithAP_AP_1", ActionPlan: []*v1.AttrActionPlan{ {ActionsId: argActs1.ActionsId, @@ -398,7 +398,7 @@ func testAPIerSv2itSetActionWithCategory(t *testing.T) { func testAPIerSv2itSetActionPlanWithWrongTiming(t *testing.T) { var reply string - tNow := time.Now().Add(time.Duration(time.Minute)).String() + tNow := time.Now().Add(time.Minute).String() argAP1 := &v1.AttrSetActionPlan{Id: "TestAPIerSv2itSetAccountWithAPWithWrongTiming", ActionPlan: []*v1.AttrActionPlan{ &v1.AttrActionPlan{ diff --git a/apier/v2/cdrs_it_test.go b/apier/v2/cdrs_it_test.go index 98cf1fbbf..d7c50e9f4 100644 --- a/apier/v2/cdrs_it_test.go +++ b/apier/v2/cdrs_it_test.go @@ -964,7 +964,7 @@ func testV2CDRsRerate(t *testing.T) { utils.Subject: "ANY2CNT", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: 1 * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, @@ -1139,7 +1139,7 @@ func testV2CDRsDuplicateCDRs(t *testing.T) { utils.Subject: "ANY2CNT", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: 1 * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, diff --git a/apier/v2/cdrs_offline_it_test.go b/apier/v2/cdrs_offline_it_test.go index 5b9ffc556..6bf268684 100644 --- a/apier/v2/cdrs_offline_it_test.go +++ b/apier/v2/cdrs_offline_it_test.go @@ -166,7 +166,7 @@ func testV2CDRsOfflineBalanceUpdate(t *testing.T) { ID: "THD_Test", FilterIDs: []string{"*string:Account:test"}, MaxHits: -1, - MinSleep: time.Duration(time.Second), + MinSleep: time.Second, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_LOG"}, @@ -197,7 +197,7 @@ func testV2CDRsOfflineBalanceUpdate(t *testing.T) { utils.Subject: "test", utils.Destination: "1002", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, }, } mapEv := engine.NewMapEvent(cgrEv.Event) @@ -211,7 +211,7 @@ func testV2CDRsOfflineBalanceUpdate(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsOfflineExpiryBalance(t *testing.T) { @@ -286,7 +286,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(0), + MinSleep: 0, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_LOG"}, @@ -319,7 +319,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) { utils.Subject: "test2", utils.Destination: "1002", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, }, }, }, @@ -330,7 +330,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsBalancesWithSameWeight(t *testing.T) { @@ -373,7 +373,7 @@ func testV2CDRsBalancesWithSameWeight(t *testing.T) { utils.Subject: "specialTest", utils.Destination: "1002", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, }, } mapEv := engine.NewMapEvent(cgrEv.Event) @@ -387,7 +387,7 @@ func testV2CDRsBalancesWithSameWeight(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsOfflineKillEngine(t *testing.T) { diff --git a/cmd/cgr-console/cgr-console.go b/cmd/cgr-console/cgr-console.go index c07dc4807..8643bf1d5 100644 --- a/cmd/cgr-console/cgr-console.go +++ b/cmd/cgr-console/cgr-console.go @@ -130,7 +130,7 @@ func main() { } var err error client, err = rpcclient.NewRPCClient(utils.TCP, *server, *tls, *keyPath, *certificatePath, *caPath, 3, 3, - time.Duration(1*time.Second), time.Duration(*replyTimeOut)*time.Second, *rpcEncoding, nil, false) + time.Second, time.Duration(*replyTimeOut)*time.Second, *rpcEncoding, nil, false) if err != nil { cgrConsoleFlags.PrintDefaults() log.Fatal("Could not connect to server " + *server) diff --git a/cmd/cgr-tester/cdr_repl/process_cdr.go b/cmd/cgr-tester/cdr_repl/process_cdr.go index 2524be689..90e809c50 100644 --- a/cmd/cgr-tester/cdr_repl/process_cdr.go +++ b/cmd/cgr-tester/cdr_repl/process_cdr.go @@ -44,7 +44,7 @@ func main() { log.Fatal("Got config error: ", err.Error()) } cdrsMasterRpc, err = rpcclient.NewRPCClient(utils.TCP, cdrsMasterCfg.ListenCfg().RPCJSONListen, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) + time.Second, 2*time.Second, rpcclient.JSONrpc, nil, false) if err != nil { log.Fatal("Could not connect to rater: ", err.Error()) } diff --git a/config/cachecfg_test.go b/config/cachecfg_test.go index 10305e8d8..0400bceec 100644 --- a/config/cachecfg_test.go +++ b/config/cachecfg_test.go @@ -31,7 +31,7 @@ func TestAsTransCacheConfig(t *testing.T) { Partitions: map[string]*CacheParamCfg{ "test": { Limit: 50, - TTL: time.Duration(60 * time.Second), + TTL: 60 * time.Second, StaticTTL: true, Precache: true, }, @@ -40,7 +40,7 @@ func TestAsTransCacheConfig(t *testing.T) { expected := map[string]*ltcache.CacheConfig{ "test": { MaxItems: 50, - TTL: time.Duration(60 * time.Second), + TTL: 60 * time.Second, StaticTTL: true, }, } @@ -65,7 +65,7 @@ func TestCacheCfgloadFromJsonCfg(t *testing.T) { } expected := &CacheCfg{ Partitions: map[string]*CacheParamCfg{ - utils.MetaDestinations: {Limit: 10, TTL: time.Duration(2), StaticTTL: true, Precache: true, Replicate: true}, + utils.MetaDestinations: {Limit: 10, TTL: 2, StaticTTL: true, Precache: true, Replicate: true}, }, ReplicationConns: []string{"conn1", "conn2"}, } @@ -106,7 +106,7 @@ func TestCacheParamCfgloadFromJsonCfg1(t *testing.T) { } expected := &CacheParamCfg{ Limit: 5, - TTL: time.Duration(time.Second), + TTL: time.Second, StaticTTL: true, Precache: true, } diff --git a/config/config_test.go b/config/config_test.go index 666c33cdd..98c42f493 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -265,7 +265,7 @@ func TestCgrCfgJSONDefaultsGeneral(t *testing.T) { if cgrCfg.GeneralCfg().Reconnects != -1 { t.Errorf("Expected: -1, received: %+v", cgrCfg.GeneralCfg().Reconnects) } - if cgrCfg.GeneralCfg().ConnectTimeout != 1*time.Second { + if cgrCfg.GeneralCfg().ConnectTimeout != time.Second { t.Errorf("Expected: 1s, received: %+v", cgrCfg.GeneralCfg().ConnectTimeout) } if cgrCfg.GeneralCfg().ReplyTimeout != 2*time.Second { @@ -382,11 +382,11 @@ func TestCgrCfgJSONDefaultsRALs(t *testing.T) { t.Errorf("Expecting: false , received: %+v", cgrCfg.RalsCfg().RpSubjectPrefixMatching) } eMaxCU := map[string]time.Duration{ - utils.ANY: time.Duration(189 * time.Hour), - utils.VOICE: time.Duration(72 * time.Hour), - utils.DATA: time.Duration(107374182400), - utils.SMS: time.Duration(10000), - utils.MMS: time.Duration(10000), + utils.ANY: 189 * time.Hour, + utils.VOICE: 72 * time.Hour, + utils.DATA: 107374182400, + utils.SMS: 10000, + utils.MMS: 10000, } if !reflect.DeepEqual(eMaxCU, cgrCfg.RalsCfg().MaxComputedUsage) { t.Errorf("Expecting: %+v , received: %+v", eMaxCU, cgrCfg.RalsCfg().MaxComputedUsage) @@ -472,9 +472,9 @@ func TestCgrCfgJSONDefaultsSMGenericCfg(t *testing.T) { RouteSConns: []string{}, AttrSConns: []string{}, ReplicationConns: []string{}, - DebitInterval: 0 * time.Second, + DebitInterval: 0, StoreSCosts: false, - SessionTTL: 0 * time.Second, + SessionTTL: 0, SessionIndexes: utils.StringMap{}, ClientProtocol: 1.0, ChannelSyncInterval: 0, @@ -571,23 +571,23 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) { utils.CacheDispatchers: {Limit: -1, TTL: 0, StaticTTL: false, Precache: false}, utils.CacheDiameterMessages: {Limit: -1, - TTL: time.Duration(3 * time.Hour), StaticTTL: false}, + TTL: 3 * time.Hour, StaticTTL: false}, utils.CacheRPCResponses: {Limit: 0, - TTL: time.Duration(2 * time.Second), StaticTTL: false}, + TTL: 2 * time.Second, StaticTTL: false}, utils.CacheClosedSessions: {Limit: -1, - TTL: time.Duration(10 * time.Second), StaticTTL: false}, + TTL: 10 * time.Second, StaticTTL: false}, utils.CacheEventCharges: {Limit: -1, - TTL: time.Duration(10 * time.Second), StaticTTL: false}, + TTL: 10 * time.Second, StaticTTL: false}, utils.CacheCDRIDs: {Limit: -1, - TTL: time.Duration(10 * time.Minute), StaticTTL: false}, + TTL: 10 * time.Minute, StaticTTL: false}, utils.CacheLoadIDs: {Limit: -1, TTL: 0, StaticTTL: false, Precache: false}, utils.CacheRPCConnections: {Limit: -1, TTL: 0, StaticTTL: false}, utils.CacheUCH: {Limit: -1, - TTL: time.Duration(3 * time.Hour), StaticTTL: false}, + TTL: 3 * time.Hour, StaticTTL: false}, utils.CacheSTIR: {Limit: -1, - TTL: time.Duration(3 * time.Hour), StaticTTL: false}, + TTL: 3 * time.Hour, StaticTTL: false}, utils.CacheVersions: {Limit: -1, TTL: 0, StaticTTL: false, Precache: false}, @@ -2020,7 +2020,7 @@ func TestCgrCdfEventExporter(t *testing.T) { Cache: map[string]*CacheParamCfg{ utils.MetaFileCSV: { Limit: -1, - TTL: time.Duration(5 * time.Second), + TTL: 5 * time.Second, StaticTTL: false, }, }, diff --git a/config/dispatcherhcfg_test.go b/config/dispatcherhcfg_test.go index 3a45b32c0..9389e88ab 100644 --- a/config/dispatcherhcfg_test.go +++ b/config/dispatcherhcfg_test.go @@ -83,7 +83,7 @@ func TestDispatcherHCfgloadFromJsonCfg(t *testing.T) { }, }, }, - RegisterInterval: time.Duration(5), + RegisterInterval: 5, } if jsnCfg, err := NewDefaultCGRConfig(); err != nil { t.Error(err) @@ -194,7 +194,7 @@ func TestDispatcherHCfgAsMapInterface1(t *testing.T) { }, }, }, - utils.RegisterIntervalCfg: 1 * time.Minute, + utils.RegisterIntervalCfg: time.Minute, } if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil { t.Error(err) diff --git a/config/eescfg_test.go b/config/eescfg_test.go index f378b1c3b..59a6276ee 100644 --- a/config/eescfg_test.go +++ b/config/eescfg_test.go @@ -67,7 +67,7 @@ func TestEESClone(t *testing.T) { Cache: map[string]*CacheParamCfg{ utils.MetaFileCSV: { Limit: -2, - TTL: time.Duration(3 * time.Second), + TTL: 3 * time.Second, StaticTTL: true, Precache: false, Replicate: false, @@ -297,7 +297,7 @@ func TestEventExporterSameID(t *testing.T) { Cache: map[string]*CacheParamCfg{ utils.MetaFileCSV: { Limit: -1, - TTL: time.Duration(5 * time.Second), + TTL: 5 * time.Second, StaticTTL: false, }, }, @@ -421,7 +421,7 @@ func TestEEsCfgloadFromJsonCfgCase1(t *testing.T) { Cache: map[string]*CacheParamCfg{ utils.MetaFileCSV: { Limit: -2, - TTL: 1 * time.Second, + TTL: time.Second, StaticTTL: false, }, }, @@ -539,7 +539,7 @@ func TestEEsCfgloadFromJsonCfgCase2(t *testing.T) { Cache: map[string]*CacheParamCfg{ utils.MetaFileCSV: { Limit: -2, - TTL: 1 * time.Second, + TTL: time.Second, StaticTTL: false, }, }, diff --git a/config/erscfg_test.go b/config/erscfg_test.go index e63e1a7d6..44042c5a7 100644 --- a/config/erscfg_test.go +++ b/config/erscfg_test.go @@ -69,7 +69,7 @@ func TestERSClone(t *testing.T) { Type: utils.META_NONE, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(0), + RunDelay: 0, ConcurrentReqs: 1024, SourcePath: "/var/spool/cgrates/ers/in", ProcessedPath: "/var/spool/cgrates/ers/out", @@ -110,7 +110,7 @@ func TestERSClone(t *testing.T) { Type: "*file_csv", FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(-1), + RunDelay: -1, ConcurrentReqs: 1024, SourcePath: "/tmp/ers/in", ProcessedPath: "/tmp/ers/out", @@ -120,7 +120,7 @@ func TestERSClone(t *testing.T) { Filters: []string{"randomFiletrs"}, Flags: utils.FlagsWithParams{}, FailedCallsPrefix: "randomPrefix", - PartialRecordCache: time.Duration(1 * time.Second), + PartialRecordCache: time.Second, PartialCacheExpiryAction: "randomAction", Fields: []*FCTemplate{ {Tag: utils.ToR, Path: utils.MetaCgreq + utils.NestingSep + utils.ToR, Type: utils.MetaVariable, @@ -225,7 +225,7 @@ func TestERSLoadFromjsonCfg(t *testing.T) { Type: utils.META_NONE, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(0), + RunDelay: 0, ConcurrentReqs: 1024, SourcePath: "/var/spool/cgrates/ers/in", ProcessedPath: "/var/spool/cgrates/ers/out", @@ -266,7 +266,7 @@ func TestERSLoadFromjsonCfg(t *testing.T) { Type: utils.MetaFileCSV, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(-1), + RunDelay: -1, ConcurrentReqs: 1024, SourcePath: "/tmp/ers/in", ProcessedPath: "/tmp/ers/out", @@ -450,7 +450,7 @@ func TestERSloadFromJsonCase3(t *testing.T) { Type: utils.META_NONE, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(0), + RunDelay: 0, ConcurrentReqs: 1024, SourcePath: "/var/spool/cgrates/ers/in", ProcessedPath: "/var/spool/cgrates/ers/out", @@ -492,7 +492,7 @@ func TestERSloadFromJsonCase3(t *testing.T) { RowLength: 5, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(-1), + RunDelay: -1, ConcurrentReqs: 1024, SourcePath: "/tmp/ers/in", ProcessedPath: "/tmp/ers/out", @@ -502,7 +502,7 @@ func TestERSloadFromJsonCase3(t *testing.T) { Filters: nil, Flags: utils.FlagsWithParams{}, PartialCacheExpiryAction: "", - PartialRecordCache: time.Duration(0), + PartialRecordCache: 0, Fields: []*FCTemplate{ { Tag: utils.CGRID, @@ -582,7 +582,7 @@ func TestERSloadFromJsonCase4(t *testing.T) { Type: utils.META_NONE, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(0), + RunDelay: 0, ConcurrentReqs: 1024, SourcePath: "/var/spool/cgrates/ers/in", ProcessedPath: "/var/spool/cgrates/ers/out", @@ -624,7 +624,7 @@ func TestERSloadFromJsonCase4(t *testing.T) { RowLength: 5, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(-1), + RunDelay: -1, ConcurrentReqs: 1024, SourcePath: "/tmp/ers/in", ProcessedPath: "/tmp/ers/out", @@ -634,7 +634,7 @@ func TestERSloadFromJsonCase4(t *testing.T) { Filters: nil, Flags: utils.FlagsWithParams{}, PartialCacheExpiryAction: "", - PartialRecordCache: time.Duration(0), + PartialRecordCache: 0, Fields: []*FCTemplate{}, CacheDumpFields: []*FCTemplate{ { @@ -703,7 +703,7 @@ func TestEventReaderSameID(t *testing.T) { Type: utils.META_NONE, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(0), + RunDelay: 0, ConcurrentReqs: 1024, SourcePath: "/var/spool/cgrates/ers/in", ProcessedPath: "/var/spool/cgrates/ers/out", @@ -745,7 +745,7 @@ func TestEventReaderSameID(t *testing.T) { RowLength: 5, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(-1), + RunDelay: -1, ConcurrentReqs: 1024, SourcePath: "/tmp/ers/in", ProcessedPath: "/tmp/ers/out", @@ -1056,7 +1056,7 @@ func TestERsloadFromJsonCfg(t *testing.T) { Type: utils.META_NONE, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(0), + RunDelay: 0, ConcurrentReqs: 1024, SourcePath: "/var/spool/cgrates/ers/in", ProcessedPath: "/var/spool/cgrates/ers/out", @@ -1098,7 +1098,7 @@ func TestERsloadFromJsonCfg(t *testing.T) { RowLength: 5, FieldSep: ",", HeaderDefineChar: ":", - RunDelay: time.Duration(-1), + RunDelay: -1, ConcurrentReqs: 1024, SourcePath: "/tmp/ers/in", ProcessedPath: "/tmp/ers/out", @@ -1108,7 +1108,7 @@ func TestERsloadFromJsonCfg(t *testing.T) { Filters: nil, Flags: utils.FlagsWithParams{}, PartialCacheExpiryAction: "", - PartialRecordCache: time.Duration(0), + PartialRecordCache: 0, Fields: []*FCTemplate{ { Tag: utils.CGRID, diff --git a/config/multifiles_it_test.go b/config/multifiles_it_test.go index 98a37930d..ecb30511d 100644 --- a/config/multifiles_it_test.go +++ b/config/multifiles_it_test.go @@ -69,9 +69,9 @@ func TestMfEnvReaderITRead(t *testing.T) { ConnectAttempts: 3, Reconnects: -1, MaxCallDuration: 3 * time.Hour, - ConnectTimeout: time.Duration(1 * time.Second), - ReplyTimeout: time.Duration(2 * time.Second), - LockingTimeout: time.Duration(0), + ConnectTimeout: time.Second, + ReplyTimeout: 2 * time.Second, + LockingTimeout: 0, DigestSeparator: ",", DigestEqual: ":", RSRSep: ";", diff --git a/config/ralscfg_test.go b/config/ralscfg_test.go index 88af4d718..ecd035af4 100644 --- a/config/ralscfg_test.go +++ b/config/ralscfg_test.go @@ -55,11 +55,11 @@ func TestRalsCfgFromJsonCfgCase1(t *testing.T) { RpSubjectPrefixMatching: true, RemoveExpired: true, MaxComputedUsage: map[string]time.Duration{ - utils.ANY: time.Duration(189 * time.Hour), - utils.VOICE: time.Duration(72 * time.Hour), - utils.DATA: time.Duration(107374182400), - utils.SMS: time.Duration(5000), - utils.MMS: time.Duration(10000), + utils.ANY: 189 * time.Hour, + utils.VOICE: 72 * time.Hour, + utils.DATA: 107374182400, + utils.SMS: 5000, + utils.MMS: 10000, }, MaxIncrements: 1000000, BalanceRatingSubject: map[string]string{ diff --git a/config/resourcescfg_test.go b/config/resourcescfg_test.go index 476adbfa8..a9619560c 100644 --- a/config/resourcescfg_test.go +++ b/config/resourcescfg_test.go @@ -39,7 +39,7 @@ func TestResourceSConfigloadFromJsonCfgCase1(t *testing.T) { expected := &ResourceSConfig{ Enabled: true, IndexedSelects: true, - StoreInterval: time.Duration(2 * time.Second), + StoreInterval: 2 * time.Second, ThresholdSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds), "*conn1"}, StringIndexedFields: &[]string{"*req.index1"}, PrefixIndexedFields: &[]string{"*req.index1"}, diff --git a/config/sessionscfg_test.go b/config/sessionscfg_test.go index 54da50e79..b720d4da7 100644 --- a/config/sessionscfg_test.go +++ b/config/sessionscfg_test.go @@ -21,7 +21,6 @@ import ( "reflect" "sort" "testing" - "time" "github.com/cgrates/cgrates/utils" ) @@ -104,19 +103,19 @@ func TestSessionSCfgloadFromJsonCfgCase1(t *testing.T) { AttrSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes), "*conn1"}, CDRsConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCDRs), "*conn1"}, ReplicationConns: []string{"*conn1"}, - DebitInterval: time.Duration(2), + DebitInterval: 2, StoreSCosts: true, - SessionTTL: time.Duration(0), + SessionTTL: 0, SessionIndexes: utils.StringMap{}, ClientProtocol: 2.5, - ChannelSyncInterval: time.Duration(10), + ChannelSyncInterval: 10, TerminateAttempts: 6, AlterableFields: utils.StringSet{}, - MinDurLowBalance: time.Duration(1), + MinDurLowBalance: 1, SchedulerConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaScheduler), "*conn1"}, STIRCfg: &STIRcfg{ AllowedAttest: utils.StringSet{utils.META_ANY: {}}, - PayloadMaxduration: time.Duration(-1), + PayloadMaxduration: -1, DefaultAttest: "A", PrivateKeyPath: "randomPath", PublicKeyPath: "randomPath", @@ -246,19 +245,19 @@ func TestSessionSCfgloadFromJsonCfgCase10(t *testing.T) { AttrSConns: []string{}, CDRsConns: []string{}, ReplicationConns: []string{}, - DebitInterval: time.Duration(0), + DebitInterval: 0, StoreSCosts: false, - SessionTTL: time.Duration(0), + SessionTTL: 0, SessionIndexes: utils.StringMap{}, ClientProtocol: 1.0, - ChannelSyncInterval: time.Duration(0), + ChannelSyncInterval: 0, TerminateAttempts: 5, AlterableFields: utils.StringSet{}, - MinDurLowBalance: time.Duration(0), + MinDurLowBalance: 0, SchedulerConns: []string{}, STIRCfg: &STIRcfg{ AllowedAttest: utils.StringSet{utils.META_ANY: {}}, - PayloadMaxduration: time.Duration(-1), + PayloadMaxduration: -1, DefaultAttest: "A", PrivateKeyPath: "", PublicKeyPath: "", @@ -471,7 +470,7 @@ func TestFsAgentCfgloadFromJsonCfgCase1(t *testing.T) { LowBalanceAnnFile: "randomFile", EmptyBalanceAnnFile: "randomEmptyFile", EmptyBalanceContext: "randomEmptyContext", - MaxWaitConnection: time.Duration(2), + MaxWaitConnection: 2, ExtraFields: RSRParsers{}, EventSocketConns: []*FsConnCfg{ { diff --git a/config/sipagentcfg_test.go b/config/sipagentcfg_test.go index 75574b2d1..4b7573db0 100644 --- a/config/sipagentcfg_test.go +++ b/config/sipagentcfg_test.go @@ -67,7 +67,7 @@ func TestSIPAgentCfgloadFromJsonCfgCase1(t *testing.T) { ListenNet: "udp", SessionSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSessionS)}, Timezone: "local", - RetransmissionTimer: time.Duration(1), + RetransmissionTimer: 1, Templates: map[string][]*FCTemplate{ utils.TemplatesCfg: { { @@ -311,7 +311,7 @@ func TestSIPAgentCfgAsMapInterface2(t *testing.T) { utils.ListenNetCfg: "udp", utils.SessionSConnsCfg: []string{"*conn1", "*conn2"}, utils.TimezoneCfg: "", - utils.RetransmissionTimerCfg: 1 * time.Second, + utils.RetransmissionTimerCfg: time.Second, utils.RequestProcessorsCfg: []map[string]interface{}{ { utils.IdCfg: "Register", diff --git a/config/statscfg_test.go b/config/statscfg_test.go index b186eaa22..cfe53255e 100644 --- a/config/statscfg_test.go +++ b/config/statscfg_test.go @@ -20,7 +20,6 @@ package config import ( "reflect" "testing" - "time" "github.com/cgrates/cgrates/utils" ) @@ -40,7 +39,7 @@ func TestStatSCfgloadFromJsonCfgCase1(t *testing.T) { expected := &StatSCfg{ Enabled: true, IndexedSelects: true, - StoreInterval: time.Duration(2), + StoreInterval: 2, StoreUncompressedLimit: 10, ThresholdSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds), "*conn1"}, StringIndexedFields: &[]string{"*req.string"}, diff --git a/config/thresholdscfg_test.go b/config/thresholdscfg_test.go index 1b7f856a7..fca35c680 100644 --- a/config/thresholdscfg_test.go +++ b/config/thresholdscfg_test.go @@ -20,7 +20,6 @@ package config import ( "reflect" "testing" - "time" "github.com/cgrates/cgrates/utils" ) @@ -38,7 +37,7 @@ func TestThresholdSCfgloadFromJsonCfgCase1(t *testing.T) { expected := &ThresholdSCfg{ Enabled: true, IndexedSelects: true, - StoreInterval: time.Duration(2), + StoreInterval: 2, StringIndexedFields: &[]string{"*req.prefix"}, PrefixIndexedFields: &[]string{"*req.index1"}, SuffixIndexedFields: &[]string{"*req.index1"}, diff --git a/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go index 558d1acbb..76a10af96 100644 --- a/dispatchers/caches_it_test.go +++ b/dispatchers/caches_it_test.go @@ -97,7 +97,6 @@ func testDspChcPing(t *testing.T) { func testDspChcLoadAfterFolder(t *testing.T) { var rcvStats map[string]*ltcache.CacheStats expStats := engine.GetDefaultEmptyCacheStats() - expStats[utils.CacheAccountActionPlans].Items = 3 expStats[utils.CacheActionPlans].Items = 1 expStats[utils.CacheActions].Items = 1 expStats[utils.CacheDestinations].Items = 4 diff --git a/dispatchers/cdrs_it_test.go b/dispatchers/cdrs_it_test.go index 8fc92115c..d5414c701 100644 --- a/dispatchers/cdrs_it_test.go +++ b/dispatchers/cdrs_it_test.go @@ -132,7 +132,7 @@ func testDspCDRsProcessEvent(t *testing.T) { utils.Subject: "1001", utils.Destination: "1002", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, @@ -227,7 +227,7 @@ func testDspCDRsProcessCDR(t *testing.T) { Subject: "1001", Destination: "1002", AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - Usage: time.Duration(2) * time.Minute, + Usage: 2 * time.Minute, }, Opts: map[string]interface{}{ utils.OptsAPIKey: "cdrs12345", @@ -334,7 +334,7 @@ func testDspCDRsV2ProcessEvent(t *testing.T) { utils.Subject: "1001", utils.Destination: "1002", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, }, }, Opts: map[string]interface{}{ @@ -386,7 +386,7 @@ func testDspCDRsV2StoreSessionCost(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) + time.Sleep(150 * time.Millisecond) if err := dispEngine.RPC.Call(utils.CDRsV2StoreSessionCost, args, &reply); err == nil || err.Error() != "SERVER_ERROR: EXISTS" { t.Error("Unexpected error: ", err) @@ -426,7 +426,7 @@ func testDspCDRsProcessEventNoAuth(t *testing.T) { utils.Subject: "1001", utils.Destination: "1002", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, @@ -509,7 +509,7 @@ func testDspCDRsProcessCDRNoAuth(t *testing.T) { Subject: "1001", Destination: "1002", AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - Usage: time.Duration(2) * time.Minute, + Usage: 2 * time.Minute, }, } if err := dispEngine.RPC.Call(utils.CDRsV1ProcessCDR, args, &reply); err != nil { @@ -604,7 +604,7 @@ func testDspCDRsV2ProcessEventNoAuth(t *testing.T) { utils.Subject: "1001", utils.Destination: "1002", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, }, }, }, @@ -650,7 +650,7 @@ func testDspCDRsV2StoreSessionCostNoAuth(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) + time.Sleep(150 * time.Millisecond) if err := dispEngine.RPC.Call(utils.CDRsV2StoreSessionCost, args, &reply); err == nil || err.Error() != "SERVER_ERROR: EXISTS" { t.Error("Unexpected error: ", err) diff --git a/dispatchers/rals_it_test.go b/dispatchers/rals_it_test.go index cedd9a3d4..7da5df1e4 100644 --- a/dispatchers/rals_it_test.go +++ b/dispatchers/rals_it_test.go @@ -97,7 +97,7 @@ func testDspRALsGetRatingPlanCost(t *testing.T) { t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID) } else if *reply.EventCost.Cost != 6.5118 { t.Error("Unexpected Cost: ", *reply.EventCost.Cost) - } else if *reply.EventCost.Usage != time.Duration(time.Hour) { + } else if *reply.EventCost.Usage != time.Hour { t.Error("Unexpected Usage: ", *reply.EventCost.Usage) } } diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go index e9d7ecb72..b739867ad 100755 --- a/dispatchers/sessions_it_test.go +++ b/dispatchers/sessions_it_test.go @@ -276,7 +276,7 @@ func testDspSessionAuthorize(t *testing.T) { } func testDspSessionInit(t *testing.T) { - initUsage := time.Duration(5 * time.Minute) + initUsage := 5 * time.Minute argsInit := &sessions.V1InitSessionArgs{ InitSession: true, AllocateResources: true, diff --git a/dispatchers/stats_it_test.go b/dispatchers/stats_it_test.go index 3d6c0ba77..88f38942a 100755 --- a/dispatchers/stats_it_test.go +++ b/dispatchers/stats_it_test.go @@ -114,7 +114,7 @@ func testDspStsGetStatFailover(t *testing.T) { utils.EVENT_NAME: "Event1", utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(135 * time.Second), + utils.Usage: 135 * time.Second, utils.COST: 123.0, utils.RunID: utils.MetaDefault, utils.Destination: "1002"}, @@ -186,9 +186,9 @@ func testDspStsTestAuthKey(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(135 * time.Second), + utils.Usage: 135 * time.Second, utils.COST: 123.0, - utils.PDD: time.Duration(12 * time.Second)}, + utils.PDD: 12 * time.Second}, }, Opts: map[string]interface{}{ utils.OptsAPIKey: "12345", @@ -229,7 +229,7 @@ func testDspStsTestAuthKey2(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(135 * time.Second), + utils.Usage: 135 * time.Second, utils.COST: 123.0, utils.RunID: utils.MetaDefault, utils.Destination: "1002"}, @@ -274,7 +274,7 @@ func testDspStsTestAuthKey2(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.RunID: utils.MetaDefault, utils.COST: 10.0, utils.Destination: "1001", @@ -354,7 +354,7 @@ func testDspStsTestAuthKey3(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, utils.RunID: utils.MetaDefault, utils.COST: 10.0, utils.Destination: "1001", diff --git a/ees/elastic_it_test.go b/ees/elastic_it_test.go index 1b0986d32..5033537de 100644 --- a/ees/elastic_it_test.go +++ b/ees/elastic_it_test.go @@ -137,7 +137,7 @@ func testElasticExportEvents(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.01, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -169,7 +169,7 @@ func testElasticExportEvents(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Nanosecond, + utils.Usage: 10 * time.Nanosecond, utils.RunID: utils.MetaDefault, utils.Cost: 0.012, "ExtraFields": map[string]string{"extra1": "val_extra1", diff --git a/ees/filecsv_it_test.go b/ees/filecsv_it_test.go index 220705ec5..f57ecc20a 100644 --- a/ees/filecsv_it_test.go +++ b/ees/filecsv_it_test.go @@ -125,7 +125,7 @@ func testCsvExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.01, }, @@ -155,7 +155,7 @@ func testCsvExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Nanosecond, + utils.Usage: 10 * time.Nanosecond, utils.RunID: utils.MetaDefault, utils.Cost: 0.012, }, @@ -185,7 +185,7 @@ func testCsvExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(1), + utils.Usage: 1, utils.RunID: utils.MetaDefault, utils.Cost: 0.15, }, @@ -205,7 +205,7 @@ func testCsvExportEvent(t *testing.T) { if err := csvRpc.Call(utils.EventExporterSv1ProcessEvent, eventSMS, &reply); err != nil { t.Error(err) } - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } func testCsvVerifyExports(t *testing.T) { @@ -257,7 +257,7 @@ func testCsvExportComposedEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.016374, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -290,7 +290,7 @@ func testCsvExportComposedEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(1), + utils.Usage: 1, utils.RunID: utils.MetaDefault, utils.Cost: 0.155462, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -309,7 +309,7 @@ func testCsvExportComposedEvent(t *testing.T) { if err := csvRpc.Call(utils.EventExporterSv1ProcessEvent, eventSMS, &reply); err != nil { t.Error(err) } - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } func testCsvVerifyComposedExports(t *testing.T) { @@ -366,7 +366,7 @@ func testCsvExportMaskedDestination(t *testing.T) { utils.Destination: "+4986517174963", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.01, }, @@ -380,7 +380,7 @@ func testCsvExportMaskedDestination(t *testing.T) { if err := csvRpc.Call(utils.EventExporterSv1ProcessEvent, eventVoice, &rply); err != nil { t.Error(err) } - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } func testCsvVerifyMaskedDestination(t *testing.T) { @@ -425,7 +425,7 @@ func testCsvExportEventWithInflateTemplate(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.01, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -457,7 +457,7 @@ func testCsvExportEventWithInflateTemplate(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Nanosecond, + utils.Usage: 10 * time.Nanosecond, utils.RunID: utils.MetaDefault, utils.Cost: 0.012, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -489,7 +489,7 @@ func testCsvExportEventWithInflateTemplate(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(1), + utils.Usage: 1, utils.RunID: utils.MetaDefault, utils.Cost: 0.15, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -511,7 +511,7 @@ func testCsvExportEventWithInflateTemplate(t *testing.T) { if err := csvRpc.Call(utils.EventExporterSv1ProcessEvent, eventSMS, &reply); err != nil { t.Error(err) } - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } func testCsvVerifyExportsWithInflateTemplate(t *testing.T) { @@ -561,7 +561,7 @@ func testCsvExportNotFoundExporter(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.01, "ExtraFields": map[string]string{"extra1": "val_extra1", diff --git a/ees/filefwv_it_test.go b/ees/filefwv_it_test.go index 527f09376..f130716f3 100644 --- a/ees/filefwv_it_test.go +++ b/ees/filefwv_it_test.go @@ -117,7 +117,7 @@ func testFwvExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 2.34567, "ExtraFields": map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, @@ -132,7 +132,7 @@ func testFwvExportEvent(t *testing.T) { if err := fwvRpc.Call(utils.EventExporterSv1ProcessEvent, event, &reply); err != nil { t.Error(err) } - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } func testFwvVerifyExports(t *testing.T) { diff --git a/ees/httpjsonmap_it_test.go b/ees/httpjsonmap_it_test.go index 401fad85a..ad5b02669 100644 --- a/ees/httpjsonmap_it_test.go +++ b/ees/httpjsonmap_it_test.go @@ -132,7 +132,7 @@ func testHTTPJsonMapExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.01, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -165,7 +165,7 @@ func testHTTPJsonMapExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Nanosecond, + utils.Usage: 10 * time.Nanosecond, utils.RunID: utils.MetaDefault, utils.Cost: 0.012, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -198,7 +198,7 @@ func testHTTPJsonMapExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(1), + utils.Usage: 1, utils.RunID: utils.MetaDefault, utils.Cost: 0.15, utils.OrderID: 10, diff --git a/ees/httppost_it_test.go b/ees/httppost_it_test.go index 8a35095f9..0dc9cd8ae 100644 --- a/ees/httppost_it_test.go +++ b/ees/httppost_it_test.go @@ -132,7 +132,7 @@ func testHTTPExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: utils.MetaDefault, utils.Cost: 1.01, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -164,7 +164,7 @@ func testHTTPExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Nanosecond, + utils.Usage: 10 * time.Nanosecond, utils.RunID: utils.MetaDefault, utils.Cost: 0.012, "ExtraFields": map[string]string{"extra1": "val_extra1", @@ -195,7 +195,7 @@ func testHTTPExportEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(1), + utils.Usage: 1, utils.RunID: utils.MetaDefault, utils.Cost: 0.15, "ExtraFields": map[string]string{"extra1": "val_extra1", diff --git a/ees/virtual_ee_it_test.go b/ees/virtual_ee_it_test.go index be6801384..debf40408 100644 --- a/ees/virtual_ee_it_test.go +++ b/ees/virtual_ee_it_test.go @@ -118,7 +118,7 @@ func testVirtExportSupplierEvent(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: "SupplierRun", utils.Cost: 1.23, }, @@ -156,7 +156,7 @@ func testVirtExportEvents(t *testing.T) { utils.Destination: "1002", utils.SetupTime: time.Unix(1383813745, 0).UTC(), utils.AnswerTime: time.Unix(1383813746, 0).UTC(), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.RunID: "SupplierRun", utils.Cost: 1.01, }, @@ -170,7 +170,7 @@ func testVirtExportEvents(t *testing.T) { if err := virtRpc.Call(utils.EventExporterSv1ProcessEvent, eventVoice, &reply); err != nil { t.Error(err) } - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } func testVirtVerifyExports(t *testing.T) { diff --git a/engine/account_test.go b/engine/account_test.go index b6c3eef2a..5a968b521 100644 --- a/engine/account_test.go +++ b/engine/account_test.go @@ -597,7 +597,7 @@ func TestDebitCreditSplitMinutesMoney(t *testing.T) { t.Error("Error debiting balance: ", err) } if cc.Timespans[0].Increments[0].BalanceInfo.Unit.UUID != "testb" || - cc.Timespans[0].Increments[0].Duration != 1*time.Second { + cc.Timespans[0].Increments[0].Duration != time.Second { t.Error("Error setting balance id to increment: ", cc.Timespans[0].Increments[0].Duration) } @@ -1550,7 +1550,7 @@ func TestMaxDurationShared(t *testing.T) { if err != nil { t.Error("Error getting max session duration from shared group: ", err) } - if duration != 1*time.Minute { + if duration != time.Minute { t.Error("Wrong max session from shared group: ", duration) } @@ -1708,7 +1708,7 @@ func TestDebitGenericBalance(t *testing.T) { Rates: RateGroups{ &RGRate{GroupIntervalStart: 0, Value: 100, - RateIncrement: 1 * time.Second, + RateIncrement: time.Second, RateUnit: time.Second}}}}, }, }, diff --git a/engine/action_trigger_test.go b/engine/action_trigger_test.go index b2c6bf21d..f03185f0c 100644 --- a/engine/action_trigger_test.go +++ b/engine/action_trigger_test.go @@ -43,7 +43,7 @@ func TestActionTriggerClone(t *testing.T) { ThresholdType: "testThresholdType", ThresholdValue: 0.1, Recurrent: true, - MinSleep: time.Duration(10), + MinSleep: 10, ExpirationDate: ttime, ActivationDate: ttime.Add(5), Weight: 0.1, @@ -61,7 +61,7 @@ func TestActionTriggerClone(t *testing.T) { ThresholdType: "testThresholdType", ThresholdValue: 0.1, Recurrent: true, - MinSleep: time.Duration(10), + MinSleep: 10, ExpirationDate: ttime, ActivationDate: ttime.Add(5), Weight: 0.1, diff --git a/engine/actions_test.go b/engine/actions_test.go index 1e3dc76a9..d66e23472 100644 --- a/engine/actions_test.go +++ b/engine/actions_test.go @@ -2368,7 +2368,7 @@ func TestActionTopUpZeroNegative(t *testing.T) { } func TestActionSetExpiry(t *testing.T) { - timeNowPlus24h := time.Now().Add(time.Duration(24 * time.Hour)) + timeNowPlus24h := time.Now().Add(24 * time.Hour) account := &Account{ ID: "cgrates.org:zeroNegative", BalanceMap: map[string]Balances{ diff --git a/engine/calldesc_test.go b/engine/calldesc_test.go index 36145ab6b..3df064557 100644 --- a/engine/calldesc_test.go +++ b/engine/calldesc_test.go @@ -199,7 +199,7 @@ func TestParallelDebit(t *testing.T) { go debitTest(t, &wg) } wg.Wait() - time.Sleep(time.Duration(10 * time.Millisecond)) + time.Sleep(10 * time.Millisecond) t1 := time.Date(2017, time.February, 2, 17, 30, 0, 0, time.UTC) t2 := time.Date(2017, time.February, 2, 17, 30, 59, 0, time.UTC) cd := &CallDescriptor{ @@ -263,7 +263,7 @@ func TestSplitSpansWeekend(t *testing.T) { RoundingMethod: "*up", RoundingDecimals: 6, Rates: RateGroups{ - &RGRate{Value: 1, RateIncrement: 1 * time.Second, RateUnit: 1 * time.Second}, + &RGRate{Value: 1, RateIncrement: time.Second, RateUnit: time.Second}, }, }, }, @@ -277,7 +277,7 @@ func TestSplitSpansWeekend(t *testing.T) { RoundingMethod: "*up", RoundingDecimals: 6, Rates: RateGroups{ - &RGRate{Value: 1, RateIncrement: 1 * time.Second, RateUnit: 1 * time.Second}, + &RGRate{Value: 1, RateIncrement: time.Second, RateUnit: time.Second}, }, }, }, @@ -291,7 +291,7 @@ func TestSplitSpansWeekend(t *testing.T) { RoundingMethod: "*up", RoundingDecimals: 6, Rates: RateGroups{ - &RGRate{Value: 1, RateIncrement: 1 * time.Second, RateUnit: 1 * time.Second}, + &RGRate{Value: 1, RateIncrement: time.Second, RateUnit: time.Second}, }, }, }, @@ -1857,7 +1857,7 @@ func TestCallDescriptorUpdateFromCGREvent(t *testing.T) { "Subject": "acc1", "Tenant": "cgrates.org", "ToR": "", - "Usage": time.Duration(30) * time.Minute, + "Usage": 30 * time.Minute, }, } cd := &CallDescriptor{ @@ -1898,7 +1898,7 @@ func TestCallDescriptorUpdateFromCGREvent(t *testing.T) { "Subject": "acc1", "Tenant": "cgrates.org", "ToR": "", - "Usage": time.Duration(40) * time.Minute, + "Usage": 40 * time.Minute, }, } if err := cd.UpdateFromCGREvent(cgrEv, []string{utils.Account, utils.Subject}); err != nil { @@ -1932,7 +1932,7 @@ func TestCallDescriptorAsCGREvent(t *testing.T) { "Subject": "max", "Tenant": "cgrates.org", "ToR": "", - "Usage": time.Duration(30) * time.Minute, + "Usage": 30 * time.Minute, }, } cgrEvent := cd.AsCGREvent() diff --git a/engine/cdr_test.go b/engine/cdr_test.go index 8ee2fb7cb..048fcca55 100644 --- a/engine/cdr_test.go +++ b/engine/cdr_test.go @@ -44,7 +44,7 @@ func TestNewCDRFromExternalCDR(t *testing.T) { Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - Usage: time.Duration(10), Cost: 1.01, PreRated: true, + Usage: 10, Cost: 1.01, PreRated: true, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } if CDR, err := NewCDRFromExternalCDR(extCdr, ""); err != nil { @@ -61,7 +61,7 @@ func TestCDRClone(t *testing.T) { Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - RunID: utils.MetaDefault, Usage: time.Duration(10), + RunID: utils.MetaDefault, Usage: 10, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, PreRated: true, } @@ -77,7 +77,7 @@ func TestFieldAsString(t *testing.T) { Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, Cost: 1.01, + Usage: 10 * time.Second, Cost: 1.01, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } prsr := config.NewRSRParserMustCompile(utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + utils.CGRID) @@ -221,7 +221,7 @@ func TestFieldsAsString(t *testing.T) { Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - RunID: utils.MetaDefault, Usage: time.Duration(10) * time.Second, + RunID: utils.MetaDefault, Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, } eVal := "call_from_1001" @@ -276,7 +276,7 @@ func TestFieldAsStringForCostDetails(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, CostDetails: NewEventCostFromCallCost(cc, "TestCDRTestCDRAsMapStringIface2", utils.MetaDefault), @@ -333,7 +333,7 @@ func TestCDRAsHttpForm(t *testing.T) { OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, Supplier: "SUPPL1", + Usage: 10 * time.Second, Supplier: "SUPPL1", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, } cdrForm := storCdr.AsHttpForm() @@ -395,7 +395,7 @@ func TestCDRAsExternalCDR(t *testing.T) { Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - RunID: utils.MetaDefault, Usage: time.Duration(10 * time.Second), Cost: 1.01, + RunID: utils.MetaDefault, Usage: 10 * time.Second, Cost: 1.01, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} expectOutCdr := &ExternalCDR{ CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), @@ -422,7 +422,7 @@ func TestUsageReqAsCD(t *testing.T) { Category: req.Category, Account: req.Account, Subject: req.Subject, Destination: req.Destination, TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - TimeEnd: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).Add(time.Duration(10)), + TimeEnd: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).Add(10), DenyNegativeAccount: true} if cd, err := req.AsCallDescriptor("", true); err != nil { t.Error(err) @@ -441,7 +441,7 @@ func TestCdrClone(t *testing.T) { CGRID: "CGRID_test", OrderID: 18, SetupTime: time.Date(2020, time.April, 18, 23, 0, 4, 0, time.UTC), - Usage: time.Duration(10), + Usage: 10, ExtraFields: map[string]string{ "test1": "_test1_", "test2": "_test2_", @@ -457,7 +457,7 @@ func TestCdrClone(t *testing.T) { CGRID: "CGRID_test", OrderID: 18, SetupTime: time.Date(2020, time.April, 18, 23, 0, 4, 0, time.UTC), - Usage: time.Duration(10), + Usage: 10, ExtraFields: map[string]string{ "test1": "_test1_", "test2": "_test2_", @@ -492,7 +492,7 @@ func TestCDRAsMapStringIface(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, } @@ -515,7 +515,7 @@ func TestCDRAsMapStringIface(t *testing.T) { utils.Destination: "+4986517174963", utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.CostSource: cdr.CostSource, utils.Cost: 1.01, utils.PreRated: false, @@ -554,7 +554,7 @@ func TestCDRTestCDRAsMapStringIface2(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, CostDetails: NewEventCostFromCallCost(cc, "TestCDRTestCDRAsMapStringIface2", utils.MetaDefault), @@ -578,7 +578,7 @@ func TestCDRTestCDRAsMapStringIface2(t *testing.T) { utils.Destination: "+4986517174963", utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.CostSource: cdr.CostSource, utils.Cost: 1.01, utils.PreRated: false, @@ -627,7 +627,7 @@ func TestCDRAsExportRecord(t *testing.T) { Destination: "+4986517174963", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, RunID: utils.MetaDefault, Cost: 1.01, ExtraFields: map[string]string{"stop_time": "2014-06-11 19:19:00 +0000 UTC", "fieldextr2": "valextr2"}, CostDetails: eventCost, @@ -840,7 +840,7 @@ func TestCDRAsCDRsql(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.01, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } @@ -910,7 +910,7 @@ func TestCDRNewCDRFromSQL(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.01, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } @@ -940,7 +940,7 @@ func TestCDRAsCGREvent(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.01, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } @@ -967,7 +967,7 @@ func TestCDRAsCGREvent(t *testing.T) { "Subject": "1001", "Tenant": "cgrates.org", "ToR": "*voice", - "Usage": time.Duration(10) * time.Second, + "Usage": 10 * time.Second, "field_extr1": "val_extr1", "fieldextr2": "valextr2", "PreRated": false, @@ -1032,7 +1032,7 @@ func TestCDRexportFieldValue(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.01, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } @@ -1066,7 +1066,7 @@ func TestCDReRoundingDecimals(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.32165, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } @@ -1192,7 +1192,7 @@ func TestCDRcombimedCdrFieldVal(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.32165, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, } @@ -1214,7 +1214,7 @@ func TestCDRcombimedCdrFieldVal(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: "testRun1", - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.22, }, { @@ -1233,7 +1233,7 @@ func TestCDRcombimedCdrFieldVal(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: "testRun2", - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, Cost: 1.764, }, } diff --git a/engine/cgrcdr_test.go b/engine/cgrcdr_test.go index a6b97f6fb..12159b548 100644 --- a/engine/cgrcdr_test.go +++ b/engine/cgrcdr_test.go @@ -52,7 +52,7 @@ func TestCgrCdrAsCDR(t *testing.T) { Destination: cgrCdr[utils.Destination], SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - Usage: time.Duration(10) * time.Second, Cost: -1, + Usage: 10 * time.Second, Cost: -1, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} if CDR := cgrCdr.AsCDR(""); !reflect.DeepEqual(expctRtCdr, CDR) { t.Errorf("Expecting %v, received: %v", expctRtCdr, CDR) @@ -89,7 +89,7 @@ func TestReplicatedCgrCdrAsCDR(t *testing.T) { Destination: cgrCdr[utils.Destination], SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 0.12, PreRated: true, } diff --git a/engine/chargers_test.go b/engine/chargers_test.go index e7ba28215..77207d450 100755 --- a/engine/chargers_test.go +++ b/engine/chargers_test.go @@ -127,7 +127,7 @@ func TestChargerAddFilter(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.UsageInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, }, } diff --git a/engine/eventcost_test.go b/engine/eventcost_test.go index 58af17358..f9da1212c 100644 --- a/engine/eventcost_test.go +++ b/engine/eventcost_test.go @@ -37,25 +37,25 @@ var testEC = &EventCost{ RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(0), + Usage: 0, Cost: 0.1, AccountingID: "9bdad10", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -67,7 +67,7 @@ var testEC = &EventCost{ RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 60, @@ -79,19 +79,19 @@ var testEC = &EventCost{ RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -181,22 +181,22 @@ var testEC = &EventCost{ Rates: ChargedRates{ "ec1a177": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, "4910ecf": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, }, }, Timings: ChargedTimings{ @@ -214,7 +214,7 @@ func TestECClone(t *testing.T) { utils.ToJSON(testEC), utils.ToJSON(ec)) } // making sure we don't influence the original values - ec.Usage = utils.DurationPointer(time.Duration(1 * time.Second)) + ec.Usage = utils.DurationPointer(time.Second) if testEC.Usage != nil { t.Error("Usage is not nil") } @@ -272,16 +272,16 @@ func TestECClone(t *testing.T) { func TestECComputeAndReset(t *testing.T) { ec := testEC.Clone() eEc := testEC.Clone() - eEc.Usage = utils.DurationPointer(time.Duration(10 * time.Minute)) + eEc.Usage = utils.DurationPointer(10 * time.Minute) eEc.Cost = utils.Float64Pointer(3.52) - eEc.Charges[0].ecUsageIdx = utils.DurationPointer(time.Duration(0)) - eEc.Charges[0].usage = utils.DurationPointer(time.Duration(1 * time.Minute)) + eEc.Charges[0].ecUsageIdx = utils.DurationPointer(0) + eEc.Charges[0].usage = utils.DurationPointer(time.Minute) eEc.Charges[0].cost = utils.Float64Pointer(0.27) - eEc.Charges[1].ecUsageIdx = utils.DurationPointer(time.Duration(1 * time.Minute)) - eEc.Charges[1].usage = utils.DurationPointer(time.Duration(1 * time.Minute)) + eEc.Charges[1].ecUsageIdx = utils.DurationPointer(time.Minute) + eEc.Charges[1].usage = utils.DurationPointer(time.Minute) eEc.Charges[1].cost = utils.Float64Pointer(0.6) - eEc.Charges[2].ecUsageIdx = utils.DurationPointer(time.Duration(5 * time.Minute)) - eEc.Charges[2].usage = utils.DurationPointer(time.Duration(1 * time.Minute)) + eEc.Charges[2].ecUsageIdx = utils.DurationPointer(5 * time.Minute) + eEc.Charges[2].usage = utils.DurationPointer(time.Minute) eEc.Charges[2].cost = utils.Float64Pointer(0.17) ec.Compute() if !reflect.DeepEqual(eEc, ec) { @@ -340,15 +340,15 @@ func TestNewEventCostFromCallCost(t *testing.T) { RoundingDecimals: 5, Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Minute), + RateUnit: time.Second, + RateIncrement: time.Minute, }, }, }, }, - DurationIndex: time.Duration(1 * time.Minute), + DurationIndex: time.Minute, MatchedSubject: "*out:cgrates.org:call:*any", MatchedPrefix: "+49", MatchedDestId: "GERMANY", @@ -376,7 +376,7 @@ func TestNewEventCostFromCallCost(t *testing.T) { CompressFactor: 1, }, &Increment{ // First 30 seconds free - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, BalanceInfo: &DebitInfo{ Unit: &UnitInfo{ @@ -391,7 +391,7 @@ func TestNewEventCostFromCallCost(t *testing.T) { CompressFactor: 30, }, &Increment{ // Minutes with special price - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, BalanceInfo: &DebitInfo{ Unit: &UnitInfo{ // Minutes with special price @@ -410,16 +410,16 @@ func TestNewEventCostFromCallCost(t *testing.T) { RoundingDecimals: 5, Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.005, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Second), + RateUnit: time.Second, + RateIncrement: time.Second, }, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.005, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Second), + RateUnit: time.Second, + RateIncrement: time.Second, }, }, }, @@ -450,15 +450,15 @@ func TestNewEventCostFromCallCost(t *testing.T) { RoundingDecimals: 5, Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Minute), + RateUnit: time.Second, + RateIncrement: time.Minute, }, }, }, }, - DurationIndex: time.Duration(1 * time.Minute), + DurationIndex: time.Minute, MatchedSubject: "*out:cgrates.org:call:*any", MatchedPrefix: "+49", MatchedDestId: "GERMANY", @@ -467,7 +467,7 @@ func TestNewEventCostFromCallCost(t *testing.T) { Increments: Increments{ &Increment{ Cost: 0.01, - Duration: time.Duration(1 * time.Second), + Duration: time.Second, BalanceInfo: &DebitInfo{ Monetary: &MonetaryInfo{UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010", ID: utils.MetaDefault, @@ -487,25 +487,25 @@ func TestNewEventCostFromCallCost(t *testing.T) { RunID: utils.MetaDefault, StartTime: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), Cost: utils.Float64Pointer(0.85), - Usage: utils.DurationPointer(time.Duration(2 * time.Minute)), + Usage: utils.DurationPointer(2 * time.Minute), Charges: []*ChargingInterval{ { RatingID: "f2518464-68b8-42f4-acec-aef23d714314", Increments: []*ChargingIncrement{ { - Usage: time.Duration(0), + Usage: 0, Cost: 0.1, AccountingID: "44e97dec-8a7e-43d0-8b0a-736d46b5613e", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "a555cde8-4bd0-408a-afbc-c3ba64888927", CompressFactor: 30, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "906bfd0f-035c-40a3-93a8-46f71627983e", CompressFactor: 30, @@ -517,24 +517,24 @@ func TestNewEventCostFromCallCost(t *testing.T) { }, }, CompressFactor: 1, - usage: utils.DurationPointer(time.Duration(60 * time.Second)), + usage: utils.DurationPointer(60 * time.Second), cost: utils.Float64Pointer(0.15), - ecUsageIdx: utils.DurationPointer(time.Duration(0)), + ecUsageIdx: utils.DurationPointer(0), }, { RatingID: "f2518464-68b8-42f4-acec-aef23d714314", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "c890a899-df43-497a-9979-38492713f57b", CompressFactor: 60, }, }, CompressFactor: 1, - usage: utils.DurationPointer(time.Duration(60 * time.Second)), + usage: utils.DurationPointer(60 * time.Second), cost: utils.Float64Pointer(0.6), - ecUsageIdx: utils.DurationPointer(time.Duration(60 * time.Second)), + ecUsageIdx: utils.DurationPointer(60 * time.Second), }, }, Rating: Rating{ @@ -602,22 +602,22 @@ func TestNewEventCostFromCallCost(t *testing.T) { Rates: ChargedRates{ "6504fb84-6b27-47a8-a1c6-c0d843959f89": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, "e5eb0f1c-3612-4e8c-b749-7f8f41dd90d4": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, }, }, Timings: ChargedTimings{ @@ -734,11 +734,11 @@ func TestECAsRefundIncrements(t *testing.T) { ToR: utils.VOICE, TimeStart: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), TimeEnd: time.Date(2017, 1, 9, 16, 28, 21, 0, time.UTC), - DurationIndex: time.Duration(10 * time.Minute), + DurationIndex: 10 * time.Minute, } eCD.Increments = Increments{ &Increment{ - Duration: time.Duration(0), + Duration: 0, Cost: 0.1, CompressFactor: 1, BalanceInfo: &DebitInfo{ @@ -747,7 +747,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, CompressFactor: 10, BalanceInfo: &DebitInfo{ @@ -756,7 +756,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "4b8b53d7-c1a1-4159-b845-4623a00a0165"}}, }, &Increment{ - Duration: time.Duration(10 * time.Second), + Duration: 10 * time.Second, Cost: 0.01, CompressFactor: 2, BalanceInfo: &DebitInfo{ @@ -765,7 +765,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, CompressFactor: 30, BalanceInfo: &DebitInfo{ @@ -776,7 +776,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.01, CompressFactor: 60, BalanceInfo: &DebitInfo{ @@ -785,7 +785,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.01, CompressFactor: 60, BalanceInfo: &DebitInfo{ @@ -794,7 +794,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.01, CompressFactor: 60, BalanceInfo: &DebitInfo{ @@ -803,7 +803,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.01, CompressFactor: 60, BalanceInfo: &DebitInfo{ @@ -812,7 +812,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, CompressFactor: 10, BalanceInfo: &DebitInfo{ @@ -821,7 +821,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "4b8b53d7-c1a1-4159-b845-4623a00a0165"}}, }, &Increment{ - Duration: time.Duration(10 * time.Second), + Duration: 10 * time.Second, Cost: 0.01, CompressFactor: 2, BalanceInfo: &DebitInfo{ @@ -830,7 +830,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, CompressFactor: 30, BalanceInfo: &DebitInfo{ @@ -841,7 +841,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, CompressFactor: 10, BalanceInfo: &DebitInfo{ @@ -850,7 +850,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "4b8b53d7-c1a1-4159-b845-4623a00a0165"}}, }, &Increment{ - Duration: time.Duration(10 * time.Second), + Duration: 10 * time.Second, Cost: 0.01, CompressFactor: 2, BalanceInfo: &DebitInfo{ @@ -859,7 +859,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, CompressFactor: 30, BalanceInfo: &DebitInfo{ @@ -870,7 +870,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, CompressFactor: 10, BalanceInfo: &DebitInfo{ @@ -879,7 +879,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "4b8b53d7-c1a1-4159-b845-4623a00a0165"}}, }, &Increment{ - Duration: time.Duration(10 * time.Second), + Duration: 10 * time.Second, Cost: 0.01, CompressFactor: 2, BalanceInfo: &DebitInfo{ @@ -888,7 +888,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, CompressFactor: 30, BalanceInfo: &DebitInfo{ @@ -899,7 +899,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, CompressFactor: 10, BalanceInfo: &DebitInfo{ @@ -908,7 +908,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "4b8b53d7-c1a1-4159-b845-4623a00a0165"}}, }, &Increment{ - Duration: time.Duration(10 * time.Second), + Duration: 10 * time.Second, Cost: 0.01, CompressFactor: 2, BalanceInfo: &DebitInfo{ @@ -917,7 +917,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, CompressFactor: 30, BalanceInfo: &DebitInfo{ @@ -928,7 +928,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, CompressFactor: 10, BalanceInfo: &DebitInfo{ @@ -937,7 +937,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "4b8b53d7-c1a1-4159-b845-4623a00a0165"}}, }, &Increment{ - Duration: time.Duration(10 * time.Second), + Duration: 10 * time.Second, Cost: 0.01, CompressFactor: 2, BalanceInfo: &DebitInfo{ @@ -946,7 +946,7 @@ func TestECAsRefundIncrements(t *testing.T) { UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}}, }, &Increment{ - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, CompressFactor: 30, BalanceInfo: &DebitInfo{ @@ -991,25 +991,25 @@ func TestECAsCallCost(t *testing.T) { RunID: utils.MetaDefault, StartTime: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), Cost: utils.Float64Pointer(0.85), - Usage: utils.DurationPointer(time.Duration(2 * time.Minute)), + Usage: utils.DurationPointer(2 * time.Minute), Charges: []*ChargingInterval{ { RatingID: "f2518464-68b8-42f4-acec-aef23d714314", Increments: []*ChargingIncrement{ { - Usage: time.Duration(0), + Usage: 0, Cost: 0.1, AccountingID: "44e97dec-8a7e-43d0-8b0a-736d46b5613e", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "a555cde8-4bd0-408a-afbc-c3ba64888927", CompressFactor: 30, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "906bfd0f-035c-40a3-93a8-46f71627983e", CompressFactor: 30, @@ -1021,7 +1021,7 @@ func TestECAsCallCost(t *testing.T) { RatingID: "f2518464-68b8-42f4-acec-aef23d714314", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "c890a899-df43-497a-9979-38492713f57b", CompressFactor: 60, @@ -1089,22 +1089,22 @@ func TestECAsCallCost(t *testing.T) { Rates: ChargedRates{ "6504fb84-6b27-47a8-a1c6-c0d843959f89": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, "e5eb0f1c-3612-4e8c-b749-7f8f41dd90d4": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, }, }, Timings: ChargedTimings{ @@ -1134,15 +1134,15 @@ func TestECAsCallCost(t *testing.T) { RoundingDecimals: 5, Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Minute), + RateUnit: time.Second, + RateIncrement: time.Minute, }, }, }, }, - DurationIndex: time.Duration(1 * time.Minute), + DurationIndex: time.Minute, MatchedSubject: "*out:cgrates.org:call:*any", MatchedPrefix: "+49", MatchedDestId: "GERMANY", @@ -1159,7 +1159,7 @@ func TestECAsCallCost(t *testing.T) { CompressFactor: 1, }, &Increment{ // First 30 seconds free - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0, BalanceInfo: &DebitInfo{ Unit: &UnitInfo{ @@ -1171,7 +1171,7 @@ func TestECAsCallCost(t *testing.T) { CompressFactor: 30, }, &Increment{ // Minutes with special price - Duration: time.Duration(1 * time.Second), + Duration: time.Second, Cost: 0.005, BalanceInfo: &DebitInfo{ Unit: &UnitInfo{ // Minutes with special price @@ -1188,16 +1188,16 @@ func TestECAsCallCost(t *testing.T) { RoundingDecimals: 5, Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.005, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Second), + RateUnit: time.Second, + RateIncrement: time.Second, }, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.005, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Second), + RateUnit: time.Second, + RateIncrement: time.Second, }, }, }, @@ -1227,15 +1227,15 @@ func TestECAsCallCost(t *testing.T) { RoundingDecimals: 5, Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateUnit: time.Duration(1 * time.Second), - RateIncrement: time.Duration(1 * time.Minute), + RateUnit: time.Second, + RateIncrement: time.Minute, }, }, }, }, - DurationIndex: time.Duration(1 * time.Minute), + DurationIndex: time.Minute, MatchedSubject: "*out:cgrates.org:call:*any", MatchedPrefix: "+49", MatchedDestId: "GERMANY", @@ -1244,7 +1244,7 @@ func TestECAsCallCost(t *testing.T) { Increments: Increments{ &Increment{ Cost: 0.01, - Duration: time.Duration(1 * time.Second), + Duration: time.Second, BalanceInfo: &DebitInfo{ Monetary: &MonetaryInfo{ UUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010"}, @@ -1264,14 +1264,14 @@ func TestECAsCallCost(t *testing.T) { func TestECTrimZeroAndFull(t *testing.T) { ec := testEC.Clone() - if srplsEC, err := ec.Trim(time.Duration(10 * time.Minute)); err != nil { + if srplsEC, err := ec.Trim(10 * time.Minute); err != nil { t.Error(err) } else if srplsEC != nil { t.Errorf("Expecting nil, got: %+v", srplsEC) } eFullSrpls := testEC.Clone() - eFullSrpls.Usage = utils.DurationPointer(time.Duration(10 * time.Minute)) - if srplsEC, err := ec.Trim(time.Duration(0)); err != nil { + eFullSrpls.Usage = utils.DurationPointer(10 * time.Minute) + if srplsEC, err := ec.Trim(0); err != nil { t.Error(err) } else if !reflect.DeepEqual(eFullSrpls, srplsEC) { t.Errorf("\tExpecting: %s,\n\treceived: %s", @@ -1298,25 +1298,25 @@ func TestECTrimMiddle1(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(0), + Usage: 0, Cost: 0.1, AccountingID: "9bdad10", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -1328,7 +1328,7 @@ func TestECTrimMiddle1(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 60, @@ -1340,7 +1340,7 @@ func TestECTrimMiddle1(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 10, @@ -1356,7 +1356,7 @@ func TestECTrimMiddle1(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 50, @@ -1368,7 +1368,7 @@ func TestECTrimMiddle1(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 60, @@ -1380,19 +1380,19 @@ func TestECTrimMiddle1(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -1402,7 +1402,7 @@ func TestECTrimMiddle1(t *testing.T) { }, } - reqDuration := time.Duration(190 * time.Second) + reqDuration := 190 * time.Second srplsEC, err := ec.Trim(reqDuration) if err != nil { t.Error(err) @@ -1410,7 +1410,7 @@ func TestECTrimMiddle1(t *testing.T) { if reqDuration != *ec.Usage { t.Errorf("Expecting request duration: %v, received: %v", reqDuration, *ec.Usage) } - eSrplsDur := time.Duration(410 * time.Second) + eSrplsDur := 410 * time.Second if srplsUsage := srplsEC.GetUsage(); srplsUsage != eSrplsDur { t.Errorf("Expecting surplus duration: %v, received: %v", eSrplsDur, srplsUsage) } @@ -1437,60 +1437,60 @@ func TestECTrimMUsage(t *testing.T) { srplsUsage time.Duration srplsCost float64 }{ - {time.Duration(5 * time.Second), time.Duration(5 * time.Second), 0.1, - time.Duration(595 * time.Second), 3.42}, - {time.Duration(10 * time.Second), time.Duration(10 * time.Second), 0.1, - time.Duration(590 * time.Second), 3.42}, - {time.Duration(15 * time.Second), time.Duration(20 * time.Second), 0.11, - time.Duration(580 * time.Second), 3.41}, - {time.Duration(20 * time.Second), time.Duration(20 * time.Second), 0.11, - time.Duration(580 * time.Second), 3.41}, - {time.Duration(25 * time.Second), time.Duration(30 * time.Second), 0.12, - time.Duration(570 * time.Second), 3.40}, - {time.Duration(38 * time.Second), time.Duration(38 * time.Second), 0.16, - time.Duration(562 * time.Second), 3.36}, - {time.Duration(60 * time.Second), time.Duration(60 * time.Second), 0.27, - time.Duration(540 * time.Second), 3.25}, - {time.Duration(62 * time.Second), time.Duration(62 * time.Second), 0.29, - time.Duration(538 * time.Second), 3.23}, - {time.Duration(120 * time.Second), time.Duration(120 * time.Second), 0.87, - time.Duration(480 * time.Second), 2.65}, - {time.Duration(121 * time.Second), time.Duration(121 * time.Second), 0.88, - time.Duration(479 * time.Second), 2.64}, - {time.Duration(180 * time.Second), time.Duration(180 * time.Second), 1.47, - time.Duration(420 * time.Second), 2.05}, - {time.Duration(250 * time.Second), time.Duration(250 * time.Second), 2.17, - time.Duration(350 * time.Second), 1.35}, - {time.Duration(299 * time.Second), time.Duration(299 * time.Second), 2.66, - time.Duration(301 * time.Second), 0.86}, - {time.Duration(300 * time.Second), time.Duration(300 * time.Second), 2.67, - time.Duration(300 * time.Second), 0.85}, - {time.Duration(302 * time.Second), time.Duration(302 * time.Second), 2.67, - time.Duration(298 * time.Second), 0.85}, - {time.Duration(310 * time.Second), time.Duration(310 * time.Second), 2.67, - time.Duration(290 * time.Second), 0.85}, - {time.Duration(316 * time.Second), time.Duration(320 * time.Second), 2.68, - time.Duration(280 * time.Second), 0.84}, - {time.Duration(320 * time.Second), time.Duration(320 * time.Second), 2.68, - time.Duration(280 * time.Second), 0.84}, - {time.Duration(321 * time.Second), time.Duration(330 * time.Second), 2.69, - time.Duration(270 * time.Second), 0.83}, - {time.Duration(330 * time.Second), time.Duration(330 * time.Second), 2.69, - time.Duration(270 * time.Second), 0.83}, - {time.Duration(331 * time.Second), time.Duration(331 * time.Second), 2.695, - time.Duration(269 * time.Second), 0.825}, - {time.Duration(359 * time.Second), time.Duration(359 * time.Second), 2.835, - time.Duration(241 * time.Second), 0.685}, - {time.Duration(360 * time.Second), time.Duration(360 * time.Second), 2.84, - time.Duration(240 * time.Second), 0.68}, - {time.Duration(376 * time.Second), time.Duration(380 * time.Second), 2.85, - time.Duration(220 * time.Second), 0.67}, - {time.Duration(391 * time.Second), time.Duration(391 * time.Second), 2.865, - time.Duration(209 * time.Second), 0.655}, - {time.Duration(479 * time.Second), time.Duration(479 * time.Second), 3.175, - time.Duration(121 * time.Second), 0.345}, - {time.Duration(599 * time.Second), time.Duration(599 * time.Second), 3.515, - time.Duration(1 * time.Second), 0.005}, + {5 * time.Second, 5 * time.Second, 0.1, + 595 * time.Second, 3.42}, + {10 * time.Second, 10 * time.Second, 0.1, + 590 * time.Second, 3.42}, + {15 * time.Second, 20 * time.Second, 0.11, + 580 * time.Second, 3.41}, + {20 * time.Second, 20 * time.Second, 0.11, + 580 * time.Second, 3.41}, + {25 * time.Second, 30 * time.Second, 0.12, + 570 * time.Second, 3.40}, + {38 * time.Second, 38 * time.Second, 0.16, + 562 * time.Second, 3.36}, + {60 * time.Second, 60 * time.Second, 0.27, + 540 * time.Second, 3.25}, + {62 * time.Second, 62 * time.Second, 0.29, + 538 * time.Second, 3.23}, + {120 * time.Second, 120 * time.Second, 0.87, + 480 * time.Second, 2.65}, + {121 * time.Second, 121 * time.Second, 0.88, + 479 * time.Second, 2.64}, + {180 * time.Second, 180 * time.Second, 1.47, + 420 * time.Second, 2.05}, + {250 * time.Second, 250 * time.Second, 2.17, + 350 * time.Second, 1.35}, + {299 * time.Second, 299 * time.Second, 2.66, + 301 * time.Second, 0.86}, + {300 * time.Second, 300 * time.Second, 2.67, + 300 * time.Second, 0.85}, + {302 * time.Second, 302 * time.Second, 2.67, + 298 * time.Second, 0.85}, + {310 * time.Second, 310 * time.Second, 2.67, + 290 * time.Second, 0.85}, + {316 * time.Second, 320 * time.Second, 2.68, + 280 * time.Second, 0.84}, + {320 * time.Second, 320 * time.Second, 2.68, + 280 * time.Second, 0.84}, + {321 * time.Second, 330 * time.Second, 2.69, + 270 * time.Second, 0.83}, + {330 * time.Second, 330 * time.Second, 2.69, + 270 * time.Second, 0.83}, + {331 * time.Second, 331 * time.Second, 2.695, + 269 * time.Second, 0.825}, + {359 * time.Second, 359 * time.Second, 2.835, + 241 * time.Second, 0.685}, + {360 * time.Second, 360 * time.Second, 2.84, + 240 * time.Second, 0.68}, + {376 * time.Second, 380 * time.Second, 2.85, + 220 * time.Second, 0.67}, + {391 * time.Second, 391 * time.Second, 2.865, + 209 * time.Second, 0.655}, + {479 * time.Second, 479 * time.Second, 3.175, + 121 * time.Second, 0.345}, + {599 * time.Second, 599 * time.Second, 3.515, + time.Second, 0.005}, } for _, tC := range testCases { t.Run(fmt.Sprintf("AtUsage:%s", tC.atUsage), func(t *testing.T) { @@ -1524,7 +1524,7 @@ func TestECMergeGT(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 103, }, @@ -1568,8 +1568,8 @@ func TestECMergeGT(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1582,7 +1582,7 @@ func TestECMergeGT(t *testing.T) { RatingID: "6a83227", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "9288f93", CompressFactor: 84, }, @@ -1626,8 +1626,8 @@ func TestECMergeGT(t *testing.T) { Rates: ChargedRates{ "52f8b0f": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1641,7 +1641,7 @@ func TestECMergeGT(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 187, }, @@ -1685,8 +1685,8 @@ func TestECMergeGT(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1707,7 +1707,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 103, }, @@ -1740,8 +1740,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1751,7 +1751,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "6a83227", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "9288f93", CompressFactor: 84, }, @@ -1784,8 +1784,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "52f8b0f": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1796,7 +1796,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 187, }, @@ -1829,8 +1829,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1845,7 +1845,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 103, }, @@ -1878,8 +1878,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1889,7 +1889,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "6a83227", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "9288f93", CompressFactor: 84, }, @@ -1922,8 +1922,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "52f8b0f": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1934,7 +1934,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 103, }, @@ -1945,7 +1945,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 84, }, @@ -1978,8 +1978,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -1994,7 +1994,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(100), + Usage: 100, AccountingID: "0d87a64", CompressFactor: 1, }, @@ -2005,7 +2005,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 103, }, @@ -2038,8 +2038,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -2049,12 +2049,12 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "6a83227", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "9288f93", CompressFactor: 42, }, { - Usage: time.Duration(10240), + Usage: 10240, AccountingID: "9288f93", CompressFactor: 20, }, @@ -2087,8 +2087,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "52f8b0f": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -2099,7 +2099,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(100), + Usage: 100, AccountingID: "0d87a64", CompressFactor: 1, }, @@ -2110,7 +2110,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 145, }, @@ -2121,7 +2121,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(10240), + Usage: 10240, AccountingID: "0d87a64", CompressFactor: 20, }, @@ -2132,12 +2132,12 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 42, }, { - Usage: time.Duration(10240), + Usage: 10240, AccountingID: "0d87a64", CompressFactor: 20, }, @@ -2170,8 +2170,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -2186,7 +2186,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 103, }, @@ -2219,8 +2219,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -2230,7 +2230,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "6a83227", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "9288f93", CompressFactor: 103, }, @@ -2263,8 +2263,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "52f8b0f": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -2275,7 +2275,7 @@ func TestECAppendCIlFromEC(t *testing.T) { RatingID: "cc68da4", Increments: []*ChargingIncrement{ { - Usage: time.Duration(102400), + Usage: 102400, AccountingID: "0d87a64", CompressFactor: 103, }, @@ -2308,8 +2308,8 @@ func TestECAppendCIlFromEC(t *testing.T) { Rates: ChargedRates{ "06dee2e": RateGroups{ &RGRate{ - RateIncrement: time.Duration(102400), - RateUnit: time.Duration(102400)}, + RateIncrement: 102400, + RateUnit: 102400}, }, }, } @@ -2369,10 +2369,10 @@ func TestECSyncKeys(t *testing.T) { Rates: ChargedRates{ "2c1a177": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, }, } @@ -2386,25 +2386,25 @@ func TestECSyncKeys(t *testing.T) { RatingID: "21a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(0), + Usage: 0, Cost: 0.1, AccountingID: "9bdad10", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "2012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -2416,7 +2416,7 @@ func TestECSyncKeys(t *testing.T) { RatingID: "21a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "2012888", CompressFactor: 60, @@ -2428,19 +2428,19 @@ func TestECSyncKeys(t *testing.T) { RatingID: "21a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "2012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -2532,22 +2532,22 @@ func TestECSyncKeys(t *testing.T) { Rates: ChargedRates{ "2c1a177": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, "4910ecf": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, }, }, Timings: ChargedTimings{ @@ -2710,7 +2710,7 @@ func TestEventCostfieldAsInterface(t *testing.T) { t.Errorf("Expecting: nil, received: %+v", rcv) } eventCost = &EventCost{ - Usage: utils.DurationPointer(time.Duration(5 * time.Minute)), + Usage: utils.DurationPointer(5 * time.Minute), } if rcv, err := eventCost.fieldAsInterface([]string{utils.Usage}); err != nil { t.Error(err) diff --git a/engine/filters_test.go b/engine/filters_test.go index ac7f7c6aa..4c283d3fb 100644 --- a/engine/filters_test.go +++ b/engine/filters_test.go @@ -447,7 +447,7 @@ func TestFilterPassGreaterThan(t *testing.T) { t.Error(err) } ev = utils.MapStorage{} - ev.Set([]string{"ACD"}, time.Duration(2*time.Minute)) + ev.Set([]string{"ACD"}, 2*time.Minute) if passes, err := rf.passGreaterThan(ev); err != nil { t.Error(err) } else if !passes { @@ -455,7 +455,7 @@ func TestFilterPassGreaterThan(t *testing.T) { } // Second ev = utils.MapStorage{} - ev.Set([]string{"ASR"}, time.Duration(20*time.Second)) + ev.Set([]string{"ASR"}, 20*time.Second) rf, err = NewFilterRule("*gte", "~ASR", []string{"10s"}) if err != nil { t.Error(err) @@ -983,7 +983,7 @@ func TestPassFilterMaxCost(t *testing.T) { } //check with max usage -1 should fail passEvent1 := map[string]interface{}{ - "MaxUsage": time.Duration(-1), + "MaxUsage": -1, } pEv := utils.MapStorage{} pEv.Set([]string{utils.MetaReq}, passEvent1) @@ -995,7 +995,7 @@ func TestPassFilterMaxCost(t *testing.T) { } //check with max usage 0 should fail passEvent2 := map[string]interface{}{ - "MaxUsage": time.Duration(0), + "MaxUsage": 0, } pEv = utils.MapStorage{} pEv.Set([]string{utils.MetaReq}, passEvent2) @@ -1007,7 +1007,7 @@ func TestPassFilterMaxCost(t *testing.T) { } //check with max usage 123 should pass passEvent3 := map[string]interface{}{ - "MaxUsage": time.Duration(123), + "MaxUsage": 123, } pEv = utils.MapStorage{} pEv.Set([]string{utils.MetaReq}, passEvent3) diff --git a/engine/fscdr_test.go b/engine/fscdr_test.go index e89bc4f39..c8e343b30 100644 --- a/engine/fscdr_test.go +++ b/engine/fscdr_test.go @@ -423,7 +423,7 @@ func TestFsCdrCDRFields(t *testing.T) { RequestType: utils.META_RATED, Tenant: "cgrates.org", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: setupTime, - AnswerTime: answerTime, Usage: time.Duration(68) * time.Second, + AnswerTime: answerTime, Usage: 68 * time.Second, Cost: -1, ExtraFields: map[string]string{"sip_user_agent": "Jitsi2.10.5550Linux"}} if CDR := fsCdr.AsCDR(""); !reflect.DeepEqual(expctCDR, CDR) { diff --git a/engine/libcdre_test.go b/engine/libcdre_test.go index 3a2c65dde..fb93f3df8 100644 --- a/engine/libcdre_test.go +++ b/engine/libcdre_test.go @@ -28,7 +28,7 @@ import ( func TestSetFldPostCacheTTL(t *testing.T) { var1 := failedPostCache - SetFailedPostCacheTTL(time.Duration(50 * time.Millisecond)) + SetFailedPostCacheTTL(50 * time.Millisecond) var2 := failedPostCache if reflect.DeepEqual(var1, var2) { t.Error("Expecting to be different") @@ -36,7 +36,7 @@ func TestSetFldPostCacheTTL(t *testing.T) { } func TestAddFldPost(t *testing.T) { - SetFailedPostCacheTTL(time.Duration(5 * time.Second)) + SetFailedPostCacheTTL(5 * time.Second) AddFailedPost("path1", "format1", "module1", "1", make(map[string]interface{})) x, ok := failedPostCache.Get(utils.ConcatenatedKey("path1", "format1", "module1")) if !ok { diff --git a/engine/libeventcost_test.go b/engine/libeventcost_test.go index 84e34b432..4f25e2b42 100755 --- a/engine/libeventcost_test.go +++ b/engine/libeventcost_test.go @@ -35,13 +35,13 @@ func TestChargingIntervalPartiallyEquals(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, }, CompressFactor: 3, @@ -53,13 +53,13 @@ func TestChargingIntervalPartiallyEquals(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, }, CompressFactor: 3, @@ -86,25 +86,25 @@ func TestChargingIntervalUsage(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, } tCi1 := ci1.Usage() - eTCi1 := time.Duration(14*time.Second + 12*time.Millisecond) + eTCi1 := 14*time.Second + 12*time.Millisecond if *tCi1 != eTCi1 { t.Errorf("Expecting: %+v, received: %+v", eTCi1, *tCi1) } @@ -118,25 +118,25 @@ func TestChargingIntervalTotalUsage(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, } tCi1 := ci1.TotalUsage() - eTCi1 := 3 * time.Duration(14*time.Second+12*time.Millisecond) + eTCi1 := 3 * (14*time.Second + 12*time.Millisecond) if *tCi1 != eTCi1 { t.Errorf("Expecting: %+v, received: %+v", eTCi1, *tCi1) } @@ -150,26 +150,26 @@ func TestChargingIntervalEventCostUsageIndex(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, } ci1.ecUsageIdx = ci1.TotalUsage() tCi1 := ci1.EventCostUsageIndex() - eTCi1 := 3 * time.Duration(14*time.Second+12*time.Millisecond) + eTCi1 := 3 * (14*time.Second + 12*time.Millisecond) if *tCi1 != eTCi1 { t.Errorf("Expecting: %+v, received: %+v", eTCi1, *tCi1) } @@ -183,19 +183,19 @@ func TestChargingIntervalStartTime(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, @@ -216,19 +216,19 @@ func TestChargingIntervalEndTime(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, @@ -249,19 +249,19 @@ func TestChargingIntervalCost(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, @@ -281,19 +281,19 @@ func TestChargingIntervalTotalCost(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, @@ -313,19 +313,19 @@ func TestChargingIntervalClone(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 2, Cost: 1.23, - Usage: time.Duration(5 * time.Second), + Usage: 5 * time.Second, }, { AccountingID: "Acc1", CompressFactor: 3, Cost: 1.23, - Usage: time.Duration(4 * time.Millisecond), + Usage: 4 * time.Millisecond, }, }, CompressFactor: 3, @@ -347,19 +347,19 @@ func TestChargingIncrementEquals(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, } ch2 := &ChargingIncrement{ AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, } ch3 := &ChargingIncrement{ AccountingID: "Acc2", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, } if eq := ch1.Equals(ch2); !eq { t.Errorf("Expecting: true, received: %+v", eq) @@ -374,7 +374,7 @@ func TestChargingIncrementClone(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, } ch2 := ch1.Clone() if !reflect.DeepEqual(ch1, ch2) { @@ -391,10 +391,10 @@ func TestChargingIncrementTotalUsage(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, } tCh1 := ch1.TotalUsage() - eTCh1 := time.Duration(4 * time.Second) + eTCh1 := 4 * time.Second if tCh1 != eTCh1 { t.Errorf("Expecting: %+v, received: %+v", eTCh1, tCh1) } @@ -405,7 +405,7 @@ func TestChargingIncrementTotalCost(t *testing.T) { AccountingID: "Acc1", CompressFactor: 2, Cost: 2.345, - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, } tCh1 := ch1.TotalCost() eTCh1 := 4.69 diff --git a/engine/libstats_test.go b/engine/libstats_test.go index ac46c2d74..db4e5af58 100644 --- a/engine/libstats_test.go +++ b/engine/libstats_test.go @@ -150,7 +150,7 @@ func TestStatRemExpired(t *testing.T) { SQItems: []SQItem{ {"cgrates.org:TestStatRemExpired_1", utils.TimePointer(time.Now())}, {"cgrates.org:TestStatRemExpired_2", utils.TimePointer(time.Now())}, - {"cgrates.org:TestStatRemExpired_3", utils.TimePointer(time.Now().Add(time.Duration(time.Minute)))}, + {"cgrates.org:TestStatRemExpired_3", utils.TimePointer(time.Now().Add(time.Minute))}, }, } asrMetric := sq.SQMetrics[utils.MetaASR].(*StatASR) @@ -250,7 +250,7 @@ func TestStatRemOnQueueLength2(t *testing.T) { utils.MetaTCD: &StatTCD{ FilterIDs: []string{"*string:~*req.Account:1002"}, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_2": {Duration: 1 * time.Minute, CompressFactor: 1}, + "cgrates.org:TestStatRemExpired_2": {Duration: time.Minute, CompressFactor: 1}, }, }, utils.MetaASR: &StatASR{ @@ -336,7 +336,7 @@ func TestStatCompress2(t *testing.T) { Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_2": {Duration: 1 * time.Minute, CompressFactor: 1}, + "cgrates.org:TestStatRemExpired_2": {Duration: time.Minute, CompressFactor: 1}, "cgrates.org:TestStatRemExpired_3": {Duration: 2 * time.Minute, CompressFactor: 1}, }, } @@ -344,7 +344,7 @@ func TestStatCompress2(t *testing.T) { Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_4": {Duration: 1*time.Minute + 30*time.Second, CompressFactor: 2}, + "cgrates.org:TestStatRemExpired_4": {Duration: time.Minute + 30*time.Second, CompressFactor: 2}, }, } sqItems := []SQItem{ @@ -404,7 +404,7 @@ func TestStatCompress3(t *testing.T) { Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_2": {Duration: 1 * time.Minute, CompressFactor: 1}, + "cgrates.org:TestStatRemExpired_2": {Duration: time.Minute, CompressFactor: 1}, "cgrates.org:TestStatRemExpired_3": {Duration: 2 * time.Minute, CompressFactor: 1}, }, } @@ -412,7 +412,7 @@ func TestStatCompress3(t *testing.T) { Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_2": {Duration: 1 * time.Minute, CompressFactor: 1}, + "cgrates.org:TestStatRemExpired_2": {Duration: time.Minute, CompressFactor: 1}, "cgrates.org:TestStatRemExpired_3": {Duration: 2 * time.Minute, CompressFactor: 1}, }, } @@ -511,14 +511,14 @@ func TestStatExpand2(t *testing.T) { Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_4": {Duration: 1*time.Minute + 30*time.Second, CompressFactor: 2}, + "cgrates.org:TestStatRemExpired_4": {Duration: time.Minute + 30*time.Second, CompressFactor: 2}, }, } tcd := &StatTCD{ Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_4": {Duration: 1*time.Minute + 30*time.Second, CompressFactor: 2}, + "cgrates.org:TestStatRemExpired_4": {Duration: time.Minute + 30*time.Second, CompressFactor: 2}, }, } expectedSqItems := []SQItem{ @@ -570,7 +570,7 @@ func TestStatExpand3(t *testing.T) { Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_2": {Duration: 1 * time.Minute, CompressFactor: 1}, + "cgrates.org:TestStatRemExpired_2": {Duration: time.Minute, CompressFactor: 1}, "cgrates.org:TestStatRemExpired_4": {Duration: 2 * time.Minute, CompressFactor: 1}, }, } @@ -578,7 +578,7 @@ func TestStatExpand3(t *testing.T) { Sum: 3 * time.Minute, Count: 2, Events: map[string]*DurationWithCompress{ - "cgrates.org:TestStatRemExpired_2": {Duration: 1 * time.Minute, CompressFactor: 1}, + "cgrates.org:TestStatRemExpired_2": {Duration: time.Minute, CompressFactor: 1}, "cgrates.org:TestStatRemExpired_4": {Duration: 2 * time.Minute, CompressFactor: 1}, }, } @@ -617,7 +617,7 @@ func TestStatExpand3(t *testing.T) { func TestStatRemoveExpiredTTL(t *testing.T) { sq = &StatQueue{ - ttl: utils.DurationPointer(time.Duration(100 * time.Millisecond)), + ttl: utils.DurationPointer(100 * time.Millisecond), SQMetrics: map[string]StatMetric{ utils.MetaASR: &StatASR{ Answered: 1, diff --git a/engine/mapevent_test.go b/engine/mapevent_test.go index ac1aedde3..2c64a52b3 100644 --- a/engine/mapevent_test.go +++ b/engine/mapevent_test.go @@ -33,7 +33,7 @@ var mapEv = MapEvent(map[string]interface{}{ "test3": 42.3, "test4": true, "test5": "test", - "test6": time.Duration(10 * time.Second), + "test6": 10 * time.Second, "test7": "42s", "test8": time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC), "test9": "2009-11-10T23:00:00Z", @@ -158,22 +158,22 @@ func TestMapEventGetStringIgnoreErrors(t *testing.T) { func TestMapEventGetDuration(t *testing.T) { if rply, err := mapEv.GetDuration("test"); err != utils.ErrNotFound { t.Errorf("Expected: %+v, received: %+v", utils.ErrNotFound, err) - } else if rply != time.Duration(0) { - t.Errorf("Expected: %+v , received duration: %+v", time.Duration(0), rply) + } else if rply != 0 { + t.Errorf("Expected: %+v , received duration: %+v", 0, rply) } - expected := time.Duration(10 * time.Second) + expected := 10 * time.Second if rply, err := mapEv.GetDuration("test6"); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = time.Duration(42 * time.Second) + expected = 42 * time.Second if rply, err := mapEv.GetDuration("test7"); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = time.Duration(42) + expected = 42 if rply, err := mapEv.GetDuration("test2"); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { @@ -182,18 +182,18 @@ func TestMapEventGetDuration(t *testing.T) { } func TestMapEventGetDurationIgnoreErrors(t *testing.T) { - if rply := mapEv.GetDurationIgnoreErrors("test"); rply != time.Duration(0) { - t.Errorf("Expected: %+v, received: %+v", time.Duration(0), rply) + if rply := mapEv.GetDurationIgnoreErrors("test"); rply != 0 { + t.Errorf("Expected: %+v, received: %+v", 0, rply) } - expected := time.Duration(10 * time.Second) + expected := 10 * time.Second if rply := mapEv.GetDurationIgnoreErrors("test6"); rply != expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } - expected = time.Duration(42 * time.Second) + expected = 42 * time.Second if rply := mapEv.GetDurationIgnoreErrors("test7"); rply != expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } - expected = time.Duration(42) + expected = 42 if rply := mapEv.GetDurationIgnoreErrors("test2"); rply != expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } @@ -462,25 +462,25 @@ func TestMapEventAsCDR(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(0), + Usage: 0, Cost: 0.1, AccountingID: "9bdad10", CompressFactor: 1, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -492,7 +492,7 @@ func TestMapEventAsCDR(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 60, @@ -504,19 +504,19 @@ func TestMapEventAsCDR(t *testing.T) { RatingID: "c1a5ab9", Increments: []*ChargingIncrement{ { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0, AccountingID: "3455b83", CompressFactor: 10, }, { - Usage: time.Duration(10 * time.Second), + Usage: 10 * time.Second, Cost: 0.01, AccountingID: "a012888", CompressFactor: 2, }, { - Usage: time.Duration(1 * time.Second), + Usage: time.Second, Cost: 0.005, AccountingID: "44d6c02", CompressFactor: 30, @@ -605,22 +605,22 @@ func TestMapEventAsCDR(t *testing.T) { Rates: ChargedRates{ "ec1a177": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.01, - RateIncrement: time.Duration(1 * time.Minute), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, "4910ecf": RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.005, - RateIncrement: time.Duration(1 * time.Second), - RateUnit: time.Duration(1 * time.Second)}, + RateIncrement: time.Second, + RateUnit: time.Second}, }, }, Timings: ChargedTimings{ @@ -648,7 +648,7 @@ func TestMapEventAsCDR(t *testing.T) { Source: "1001", CostSource: "1002", PreRated: true, - Usage: time.Duration(42 * time.Second), + Usage: 42 * time.Second, SetupTime: time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC), ExtraFields: map[string]string{ "ExtraField1": "5", @@ -720,19 +720,19 @@ func TestMapEventGetDurationPtr(t *testing.T) { } else if rply != nil { t.Errorf("Expected: %+v , received duration: %+v", nil, rply) } - expected := utils.DurationPointer(time.Duration(10 * time.Second)) + expected := utils.DurationPointer(10 * time.Second) if rply, err := mapEv.GetDurationPtr("test6"); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = utils.DurationPointer(time.Duration(42 * time.Second)) + expected = utils.DurationPointer(42 * time.Second) if rply, err := mapEv.GetDurationPtr("test7"); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = utils.DurationPointer(time.Duration(42)) + expected = utils.DurationPointer(42) if rply, err := mapEv.GetDurationPtr("test2"); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { @@ -744,15 +744,15 @@ func TestMapEventGetDurationPtrIgnoreErrors(t *testing.T) { if rply := mapEv.GetDurationPtrIgnoreErrors("test"); rply != nil { t.Errorf("Expected: %+v, received: %+v", nil, rply) } - expected := utils.DurationPointer(time.Duration(10 * time.Second)) + expected := utils.DurationPointer(10 * time.Second) if rply := mapEv.GetDurationPtrIgnoreErrors("test6"); *rply != *expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } - expected = utils.DurationPointer(time.Duration(42 * time.Second)) + expected = utils.DurationPointer(42 * time.Second) if rply := mapEv.GetDurationPtrIgnoreErrors("test7"); *rply != *expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } - expected = utils.DurationPointer(time.Duration(42)) + expected = utils.DurationPointer(42) if rply := mapEv.GetDurationPtrIgnoreErrors("test2"); *rply != *expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } @@ -760,11 +760,11 @@ func TestMapEventGetDurationPtrIgnoreErrors(t *testing.T) { func TestMapEventGetDurationPtrOrDefault(t *testing.T) { mapEv := NewMapEvent(nil) - dflt := time.Duration(1) + dflt := time.Nanosecond if ptr, _ := mapEv.GetDurationPtrOrDefault("test7", &dflt); dflt.String() != ptr.String() { t.Errorf("Expected: %+v, received: %+v", dflt, ptr) } - newVal := time.Duration(2) + newVal := 2 * time.Nanosecond mapEv["test7"] = newVal if ptr, _ := mapEv.GetDurationPtrOrDefault("test7", &dflt); newVal.String() != ptr.String() { t.Errorf("Expected: %+v, received: %+v", newVal, ptr) diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 4b1544560..67573d5a9 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -2099,7 +2099,7 @@ func TestStatQueueProfileToAPI(t *testing.T) { MetricID: "*tcc", }, }, - TTL: time.Duration(1 * time.Second), + TTL: time.Second, ThresholdIDs: []string{"THRESH1", "THRESH2"}, FilterIDs: []string{"FLTR_1"}, Weight: 20.0, @@ -2526,7 +2526,7 @@ func TestThresholdProfileToAPI(t *testing.T) { }, MaxHits: 12, MinHits: 10, - MinSleep: time.Duration(1 * time.Second), + MinSleep: time.Second, Weight: 20.0, ActionIDs: []string{"WARN3"}, } @@ -4167,16 +4167,16 @@ func TestRateProfileToAPI(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -4186,10 +4186,10 @@ func TestRateProfileToAPI(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -4199,10 +4199,10 @@ func TestRateProfileToAPI(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -4292,16 +4292,16 @@ func TestAPIToRateProfile(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -4311,10 +4311,10 @@ func TestAPIToRateProfile(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -4324,10 +4324,10 @@ func TestAPIToRateProfile(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, diff --git a/engine/rateinterval_test.go b/engine/rateinterval_test.go index 56e7a90db..e6abeb55a 100644 --- a/engine/rateinterval_test.go +++ b/engine/rateinterval_test.go @@ -387,13 +387,13 @@ func TestRateIntervalCost(t *testing.T) { func TestRateGroupsEquals(t *testing.T) { rg1 := RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.1, RateIncrement: time.Minute, RateUnit: 60 * time.Second, }, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.05, RateIncrement: time.Second, RateUnit: time.Second, @@ -401,13 +401,13 @@ func TestRateGroupsEquals(t *testing.T) { } rg2 := RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.1, RateIncrement: time.Minute, RateUnit: 60 * time.Second, }, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.05, RateIncrement: time.Second, RateUnit: time.Second, @@ -418,13 +418,13 @@ func TestRateGroupsEquals(t *testing.T) { } rg2 = RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.1, RateIncrement: time.Minute, RateUnit: 60 * time.Second, }, &RGRate{ - GroupIntervalStart: time.Duration(60 * time.Second), + GroupIntervalStart: 60 * time.Second, Value: 0.3, RateIncrement: time.Second, RateUnit: time.Second, @@ -435,7 +435,7 @@ func TestRateGroupsEquals(t *testing.T) { } rg2 = RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(0), + GroupIntervalStart: 0, Value: 0.1, RateIncrement: time.Minute, RateUnit: 60 * time.Second, @@ -534,10 +534,10 @@ func TestRIRateClone(t *testing.T) { MaxCostStrategy: "MaxCostStrategy_test", Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(10), + GroupIntervalStart: 10, Value: 0.7, - RateIncrement: time.Duration(10), - RateUnit: time.Duration(10), + RateIncrement: 10, + RateUnit: 10, }, }, } @@ -549,10 +549,10 @@ func TestRIRateClone(t *testing.T) { MaxCostStrategy: "MaxCostStrategy_test", Rates: RateGroups{ &RGRate{ - GroupIntervalStart: time.Duration(10), + GroupIntervalStart: 10, Value: 0.7, - RateIncrement: time.Duration(10), - RateUnit: time.Duration(10), + RateIncrement: 10, + RateUnit: 10, }, }, } @@ -560,8 +560,8 @@ func TestRIRateClone(t *testing.T) { if !reflect.DeepEqual(cln, *cloned) { t.Errorf("Expecting: %+v, received: %+v", cln, *cloned) } - rit.Rates[0].GroupIntervalStart = time.Duration(7) - if cloned.Rates[0].GroupIntervalStart != time.Duration(10) { + rit.Rates[0].GroupIntervalStart = 7 + if cloned.Rates[0].GroupIntervalStart != 10 { t.Errorf("\nExpecting: 10,\n received: %+v", cloned.Rates[0].GroupIntervalStart) } } diff --git a/engine/rateprofile_test.go b/engine/rateprofile_test.go index e2ba42440..2dede01e2 100644 --- a/engine/rateprofile_test.go +++ b/engine/rateprofile_test.go @@ -39,16 +39,16 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -58,28 +58,28 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(1 * time.Second), + IntervalStart: time.Second, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Second), + IntervalStart: time.Second, Value: 0.19, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(15 * time.Second), + IntervalStart: 15 * time.Second, Value: 0.4, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(10 * time.Second), + IntervalStart: 10 * time.Second, Value: 0.27, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -89,22 +89,22 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(10 * time.Second), + IntervalStart: 10 * time.Second, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.18, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(18 * time.Second), + IntervalStart: 18 * time.Second, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -114,10 +114,10 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -133,16 +133,16 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -152,22 +152,22 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(10 * time.Second), + IntervalStart: 10 * time.Second, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(18 * time.Second), + IntervalStart: 18 * time.Second, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.18, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -177,28 +177,28 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(1 * time.Second), + IntervalStart: time.Second, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Second), + IntervalStart: time.Second, Value: 0.19, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(10 * time.Second), + IntervalStart: 10 * time.Second, Value: 0.27, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, { - IntervalStart: time.Duration(15 * time.Second), + IntervalStart: 15 * time.Second, Value: 0.4, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -208,10 +208,10 @@ func TestRateProfileSort(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -346,14 +346,14 @@ func TestRateProfileRunTimes(t *testing.T) { ID: "RATE0", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, } rt.Compile() sTime := time.Date(2020, time.June, 28, 18, 56, 05, 0, time.UTC) - eTime := sTime.Add(time.Duration(2 * time.Minute)) + eTime := sTime.Add(2 * time.Minute) eRTimes := [][]time.Time{ {time.Date(2020, time.June, 28, 18, 56, 0, 0, time.UTC), time.Time{}}, @@ -374,7 +374,7 @@ func TestRateProfileRunTimes(t *testing.T) { // sTime and eTime inside the activation interval sTime = time.Date(2020, 12, 24, 12, 0, 0, 0, time.UTC) - eTime = sTime.Add(time.Duration(time.Hour)) + eTime = sTime.Add(time.Hour) eRTimes = [][]time.Time{ {time.Date(2020, 12, 24, 12, 0, 0, 0, time.UTC), time.Date(2020, 12, 25, 0, 0, 0, 0, time.UTC)}, } @@ -385,7 +385,7 @@ func TestRateProfileRunTimes(t *testing.T) { } // sTime smaller than activation time, eTime equals aTime sTime = time.Date(2020, 12, 23, 23, 0, 0, 0, time.UTC) - eTime = sTime.Add(time.Duration(time.Hour)) + eTime = sTime.Add(time.Hour) eRTimes = nil // cannot cover full interval if rTimes, err := rt.RunTimes(sTime, eTime, 10); err != nil { t.Error(err) @@ -395,7 +395,7 @@ func TestRateProfileRunTimes(t *testing.T) { // sTime smaller than activation time but first aTime inside, eTime inside activation interval sTime = time.Date(2020, 12, 23, 23, 59, 59, 0, time.UTC) - eTime = sTime.Add(time.Duration(time.Hour)) + eTime = sTime.Add(time.Hour) eRTimes = [][]time.Time{ {time.Date(2020, 12, 24, 0, 0, 0, 0, time.UTC), time.Date(2020, 12, 25, 0, 0, 0, 0, time.UTC)}, } @@ -423,7 +423,7 @@ func TestRateProfileRunTimesMaxIterations(t *testing.T) { ID: "RATE0", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, ActivationTimes: "* * 24 12 *", @@ -445,7 +445,7 @@ func TestRateProfileRunTimesPassingActivationTIme(t *testing.T) { ID: "RATE0", IntervalRates: []*IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, ActivationTimes: "* * 24 * *", diff --git a/engine/ratingplan_test.go b/engine/ratingplan_test.go index e6fbd74dd..988704175 100644 --- a/engine/ratingplan_test.go +++ b/engine/ratingplan_test.go @@ -178,13 +178,13 @@ func TestApAddIntervalIfNotPresent(t *testing.T) { func TestApAddRateIntervalGroups(t *testing.T) { i1 := &RateInterval{ - Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1, 1 * time.Second, 1 * time.Second}}}, + Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1, time.Second, time.Second}}}, } i2 := &RateInterval{ - Rating: &RIRate{Rates: RateGroups{&RGRate{30 * time.Second, 2, 1 * time.Second, 1 * time.Second}}}, + Rating: &RIRate{Rates: RateGroups{&RGRate{30 * time.Second, 2, time.Second, time.Second}}}, } i3 := &RateInterval{ - Rating: &RIRate{Rates: RateGroups{&RGRate{30 * time.Second, 2, 1 * time.Second, 1 * time.Second}}}, + Rating: &RIRate{Rates: RateGroups{&RGRate{30 * time.Second, 2, time.Second, time.Second}}}, } ap := &RatingPlan{} ap.AddRateInterval("NAT", i1) @@ -331,11 +331,11 @@ func TestRatingPlanSaneRatingsEqual(t *testing.T) { tag: "first", Rates: RateGroups{ &RGRate{ - GroupIntervalStart: 0 * time.Second, + GroupIntervalStart: 0, RateIncrement: 30 * time.Second, }, &RGRate{ - GroupIntervalStart: 0 * time.Second, + GroupIntervalStart: 0, RateIncrement: 30 * time.Second, }, }, @@ -354,7 +354,7 @@ func TestRatingPlanSaneRatingsNotMultiple(t *testing.T) { tag: "first", Rates: RateGroups{ &RGRate{ - GroupIntervalStart: 0 * time.Second, + GroupIntervalStart: 0, RateIncrement: 30 * time.Second, }, &RGRate{ @@ -379,12 +379,12 @@ func TestRatingPlanSaneRatingsGoot(t *testing.T) { &RGRate{ GroupIntervalStart: 60 * time.Second, RateIncrement: 30 * time.Second, - RateUnit: 1 * time.Second, + RateUnit: time.Second, }, &RGRate{ - GroupIntervalStart: 0 * time.Second, + GroupIntervalStart: 0, RateIncrement: 30 * time.Second, - RateUnit: 1 * time.Second, + RateUnit: time.Second, }, }, }, diff --git a/engine/responder_test.go b/engine/responder_test.go index 7ef974dfb..1e01710a6 100644 --- a/engine/responder_test.go +++ b/engine/responder_test.go @@ -54,8 +54,8 @@ func TestResponderGobSMCost(t *testing.T) { Rates: RateGroups{&RGRate{ GroupIntervalStart: 0, Value: 0, - RateIncrement: 1 * time.Second, - RateUnit: 1 * time.Second, + RateIncrement: time.Second, + RateUnit: time.Second, }, }, }, @@ -63,7 +63,7 @@ func TestResponderGobSMCost(t *testing.T) { }, DurationIndex: 0, Increments: Increments{&Increment{ - Duration: 1 * time.Second, + Duration: time.Second, Cost: 0, BalanceInfo: &DebitInfo{ Unit: &UnitInfo{ @@ -127,28 +127,28 @@ func TestResponderGobSMCost(t *testing.T) { func TestResponderUsageAllow(t *testing.T) { rsp := &Responder{ MaxComputedUsage: map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, }, } - if allow := rsp.usageAllowed(utils.VOICE, time.Duration(17*time.Second)); !allow { + if allow := rsp.usageAllowed(utils.VOICE, 17*time.Second); !allow { t.Errorf("Expected true, received : %+v", allow) } - if allow := rsp.usageAllowed(utils.VOICE, time.Duration(22*time.Second)); allow { + if allow := rsp.usageAllowed(utils.VOICE, 22*time.Second); allow { t.Errorf("Expected false, received : %+v", allow) } - if allow := rsp.usageAllowed(utils.DATA, time.Duration(7*time.Second)); !allow { + if allow := rsp.usageAllowed(utils.DATA, 7*time.Second); !allow { t.Errorf("Expected true, received : %+v", allow) } - if allow := rsp.usageAllowed(utils.DATA, time.Duration(12*time.Second)); allow { + if allow := rsp.usageAllowed(utils.DATA, 12*time.Second); allow { t.Errorf("Expected false, received : %+v", allow) } } func TestResponderGetCostMaxUsageANY(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:11Z", "") @@ -174,8 +174,8 @@ func TestResponderGetCostMaxUsageANY(t *testing.T) { func TestResponderGetCostMaxUsageVOICE(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:21Z", "") @@ -201,8 +201,8 @@ func TestResponderGetCostMaxUsageVOICE(t *testing.T) { func TestResponderDebitMaxUsageANY(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:11Z", "") @@ -228,8 +228,8 @@ func TestResponderDebitMaxUsageANY(t *testing.T) { func TestResponderDebitMaxUsageVOICE(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:21Z", "") @@ -255,8 +255,8 @@ func TestResponderDebitMaxUsageVOICE(t *testing.T) { func TestResponderMaxDebitMaxUsageANY(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:11Z", "") @@ -282,8 +282,8 @@ func TestResponderMaxDebitMaxUsageANY(t *testing.T) { func TestResponderMaxDebitMaxUsageVOICE(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:21Z", "") @@ -309,8 +309,8 @@ func TestResponderMaxDebitMaxUsageVOICE(t *testing.T) { func TestResponderRefundIncrementsMaxUsageANY(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:11Z", "") @@ -336,8 +336,8 @@ func TestResponderRefundIncrementsMaxUsageANY(t *testing.T) { func TestResponderRefundIncrementsMaxUsageVOICE(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:21Z", "") @@ -363,8 +363,8 @@ func TestResponderRefundIncrementsMaxUsageVOICE(t *testing.T) { func TestResponderRefundRoundingMaxUsageANY(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:11Z", "") @@ -390,8 +390,8 @@ func TestResponderRefundRoundingMaxUsageANY(t *testing.T) { func TestResponderRefundRoundingMaxUsageVOICE(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:21Z", "") @@ -417,8 +417,8 @@ func TestResponderRefundRoundingMaxUsageVOICE(t *testing.T) { func TestResponderGetMaxSessionTimeMaxUsageANY(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:11Z", "") @@ -444,8 +444,8 @@ func TestResponderGetMaxSessionTimeMaxUsageANY(t *testing.T) { func TestResponderGetMaxSessionTimeMaxUsageVOICE(t *testing.T) { rsponder.MaxComputedUsage = map[string]time.Duration{ - utils.ANY: time.Duration(10 * time.Second), - utils.VOICE: time.Duration(20 * time.Second), + utils.ANY: 10 * time.Second, + utils.VOICE: 20 * time.Second, } tStart, _ := utils.ParseTimeDetectLayout("2013-08-07T17:30:00Z", "") tEnd, _ := utils.ParseTimeDetectLayout("2013-08-07T17:31:21Z", "") diff --git a/engine/routes.go b/engine/routes.go index a1b85e222..8936bad06 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -521,7 +521,7 @@ func (rpS *RouteService) populateSortingData(ev *utils.CGREvent, route *Route, // for event based on filters and sorting algorithms func (rpS *RouteService) sortedRoutesForEvent(tnt string, args *ArgsGetRoutes) (sortedRoutes *SortedRoutes, err error) { if _, has := args.CGREvent.Event[utils.Usage]; !has { - args.CGREvent.Event[utils.Usage] = time.Duration(time.Minute) // make sure we have default set for Usage + args.CGREvent.Event[utils.Usage] = time.Minute // make sure we have default set for Usage } var rPrfs []*RouteProfile if rPrfs, err = rpS.matchingRouteProfilesForEvent(tnt, args.CGREventWithOpts, true); err != nil { diff --git a/engine/routes_test.go b/engine/routes_test.go index 8aa78467b..d6b6b5eda 100644 --- a/engine/routes_test.go +++ b/engine/routes_test.go @@ -27,7 +27,7 @@ import ( ) var ( - expTimeRoutes = time.Now().Add(time.Duration(20 * time.Minute)) + expTimeRoutes = time.Now().Add(20 * time.Minute) routeService *RouteService dmSPP *DataManager sppTest = RouteProfiles{ @@ -321,7 +321,7 @@ func TestRoutesAddFilters(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.UsageInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, @@ -343,7 +343,7 @@ func TestRoutesAddFilters(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.PddInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, diff --git a/engine/safevent_test.go b/engine/safevent_test.go index 22b254f63..41fbdbd77 100644 --- a/engine/safevent_test.go +++ b/engine/safevent_test.go @@ -32,7 +32,7 @@ var sMap = map[string]interface{}{ "test3": 42.3, "test4": true, "test5": "test", - "test6": time.Duration(10 * time.Second), + "test6": 10 * time.Second, "test7": "42s", "test8": time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC), "test9": "2009-11-10T23:00:00Z", @@ -296,7 +296,7 @@ func TestSafEventGetDuration(t *testing.T) { }) t.Run("set", func(t *testing.T) { t.Parallel() - safEv.Set("test6", time.Duration(10*time.Second)) + safEv.Set("test6", 10*time.Second) }) t.Run("remove", func(t *testing.T) { t.Parallel() @@ -311,13 +311,13 @@ func TestSafEventGetDuration(t *testing.T) { t.Errorf("Expecting: error,received: %+v", rply) } safEv.Set("test7", "42s") - expected := time.Duration(42 * time.Second) + expected := 42 * time.Second if rply, err := safEv.GetDuration("test7"); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = time.Duration(10 * time.Second) + expected = 10 * time.Second safEv.Set("test6", expected) if rply, err := safEv.GetDuration("test6"); err != nil { t.Error(err) @@ -334,7 +334,7 @@ func TestSafEventGetDurationIgnoreErrors(t *testing.T) { }) t.Run("set", func(t *testing.T) { t.Parallel() - safEv.Set("test6", time.Duration(10*time.Second)) + safEv.Set("test6", 10*time.Second) }) t.Run("remove", func(t *testing.T) { t.Parallel() @@ -342,15 +342,15 @@ func TestSafEventGetDurationIgnoreErrors(t *testing.T) { }) } safEv.Remove("test7") - if rply := safEv.GetDurationIgnoreErrors("test7"); rply != time.Duration(0) { - t.Errorf("Expecting: %+v ,received: %+v", time.Duration(0), rply) + if rply := safEv.GetDurationIgnoreErrors("test7"); rply != 0 { + t.Errorf("Expecting: %+v ,received: %+v", 0, rply) } safEv.Set("test7", "42s") - expected := time.Duration(42 * time.Second) + expected := 42 * time.Second if rply := safEv.GetDurationIgnoreErrors("test7"); !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = time.Duration(10 * time.Second) + expected = 10 * time.Second safEv.Set("test6", expected) if rply := safEv.GetDurationIgnoreErrors("test6"); !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) @@ -367,7 +367,7 @@ func TestSafEventGetDurationPtr(t *testing.T) { }) t.Run("set", func(t *testing.T) { t.Parallel() - safEv.Set("test6", time.Duration(10*time.Second)) + safEv.Set("test6", 10*time.Second) }) t.Run("remove", func(t *testing.T) { t.Parallel() @@ -382,13 +382,13 @@ func TestSafEventGetDurationPtr(t *testing.T) { t.Errorf("Expecting: error,received: %+v", rply) } safEv.Set("test7", "42s") - expected := time.Duration(42 * time.Second) + expected := 42 * time.Second if rply, err := safEv.GetDurationPtr("test7"); err != nil { t.Error(err) } else if !reflect.DeepEqual(&expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = time.Duration(10 * time.Second) + expected = 10 * time.Second safEv.Set("test6", expected) if rply, err := safEv.GetDurationPtr("test6"); err != nil { t.Error(err) @@ -398,7 +398,7 @@ func TestSafEventGetDurationPtr(t *testing.T) { } func TestSafEventGetDurationPtrOrDefault(t *testing.T) { - def := time.Duration(450) + def := 450 * time.Nanosecond for i := 0; i < 10; i++ { t.Run("getDurationPtrDef", func(t *testing.T) { t.Parallel() @@ -408,7 +408,7 @@ func TestSafEventGetDurationPtrOrDefault(t *testing.T) { }) t.Run("set", func(t *testing.T) { t.Parallel() - safEv.Set("test6", time.Duration(10*time.Second)) + safEv.Set("test6", 10*time.Second) }) t.Run("remove", func(t *testing.T) { t.Parallel() @@ -425,13 +425,13 @@ func TestSafEventGetDurationPtrOrDefault(t *testing.T) { t.Errorf("Expecting: error,received: %+v", rply) } safEv.Set("test7", "42s") - expected := time.Duration(42 * time.Second) + expected := 42 * time.Second if rply, err := safEv.GetDurationPtrOrDefault("test7", &def); err != nil { t.Error(err) } else if !reflect.DeepEqual(&expected, rply) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } - expected = time.Duration(10 * time.Second) + expected = 10 * time.Second safEv.Set("test6", expected) if rply, err := safEv.GetDurationPtrOrDefault("test6", &def); err != nil { t.Error(err) @@ -729,7 +729,7 @@ func TestSafEventAsCDR(t *testing.T) { Source: "1001", CostSource: "1002", PreRated: true, - Usage: time.Duration(42 * time.Second), + Usage: 42 * time.Second, SetupTime: time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC), ExtraFields: map[string]string{ "ExtraField1": "5", @@ -774,15 +774,15 @@ func TestSafEventGetDurationPtrIgnoreErrors(t *testing.T) { if rply := safEv.GetDurationPtrIgnoreErrors("test"); rply != nil { t.Errorf("Expected: %+v, received: %+v", nil, rply) } - // expected := utils.DurationPointer(time.Duration(10 * time.Second)) + // expected := utils.DurationPointer(10*Second) // if rply := safEv.GetDurationPtrIgnoreErrors("test6"); rply == nil || *rply != *expected { // t.Errorf("Expected: %+v, received: %+v", expected, rply) // } - expected := utils.DurationPointer(time.Duration(42 * time.Second)) + expected := utils.DurationPointer(42 * time.Second) if rply := safEv.GetDurationPtrIgnoreErrors("test7"); rply == nil || *rply != *expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } - expected = utils.DurationPointer(time.Duration(42)) + expected = utils.DurationPointer(42) if rply := safEv.GetDurationPtrIgnoreErrors("test2"); rply == nil || *rply != *expected { t.Errorf("Expected: %+v, received: %+v", expected, rply) } @@ -790,14 +790,14 @@ func TestSafEventGetDurationPtrIgnoreErrors(t *testing.T) { func TestSafEventGetDurationOrDefault(t *testing.T) { safEv.Remove("test7") - expected := time.Duration(10 * time.Second) - if rply, err := safEv.GetDurationOrDefault("test7", time.Duration(10*time.Second)); err != nil { + expected := 10 * time.Second + if rply, err := safEv.GetDurationOrDefault("test7", 10*time.Second); err != nil { t.Error(err) } else if rply != expected { t.Errorf("Expecting %+v, received: %+v", expected, rply) } safEv.Set("test7", "42s") - expected = time.Duration(42 * time.Second) + expected = 42 * time.Second if rply, err := safEv.GetDurationOrDefault("test7", time.Second); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, rply) { diff --git a/engine/statmetrics_test.go b/engine/statmetrics_test.go index 49337aeef..0f5183ece 100644 --- a/engine/statmetrics_test.go +++ b/engine/statmetrics_test.go @@ -325,7 +325,7 @@ func TestACDGetStringValue(t *testing.T) { acd, _ := NewACD(2, "", []string{}) ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ - utils.Usage: time.Duration(10 * time.Second), + utils.Usage: 10 * time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }} if strVal := acd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { @@ -357,13 +357,13 @@ func TestACDGetStringValue(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(478433753 * time.Nanosecond), + "Usage": 478433753 * time.Nanosecond, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(30*time.Second + 982433452*time.Nanosecond), + "Usage": 30*time.Second + 982433452*time.Nanosecond, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } @@ -390,12 +390,12 @@ func TestACDGetStringValue(t *testing.T) { func TestACDGetStringValue2(t *testing.T) { acd, _ := NewACD(2, "", []string{}) ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} if err := acd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}); err != nil { t.Error(err) } ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} acd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) if strVal := acd.GetStringValue(""); strVal != "1m30s" { t.Errorf("wrong acd value: %s", strVal) @@ -425,11 +425,11 @@ func TestACDGetStringValue3(t *testing.T) { } expected.GetStringValue("") ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(3 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 3 * time.Minute}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} if err := acd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}); err != nil { t.Error(err) } @@ -470,11 +470,11 @@ func TestACDCompress(t *testing.T) { } expected.GetStringValue("") ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(3 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 3 * time.Minute}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} acd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}) acd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) acd.AddEvent(ev3.ID, utils.MapStorage{utils.MetaReq: ev3.Event}) @@ -518,11 +518,11 @@ func TestACDGetCompressFactor(t *testing.T) { acd, _ := NewACD(2, "", []string{}) ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} acd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) acd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) @@ -547,7 +547,7 @@ func TestACDGetFloat64Value(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second)}} + "Usage": 10 * time.Second}} acd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) if v := acd.GetFloat64Value(); v != -1.0 { t.Errorf("wrong acd value: %v", v) @@ -559,13 +559,13 @@ func TestACDGetFloat64Value(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), }, } @@ -625,53 +625,53 @@ func TestACDGetValue(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second)}} + "Usage": 10 * time.Second}} acd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) - if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := acd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong acd value: %+v", v) } ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(8 * time.Second)}} + "Usage": 8 * time.Second}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3"} acd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) acd.AddEvent(ev3.ID, utils.MapStorage{utils.MetaReq: ev3.Event}) - if v := acd.GetValue(); v != time.Duration(9*time.Second) { + if v := acd.GetValue(); v != 9*time.Second { t.Errorf("wrong acd value: %+v", v) } acd.RemEvent(ev.ID) - if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := acd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong acd value: %+v", v) } acd.RemEvent(ev2.ID) - if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := acd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong acd value: %+v", v) } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(4*time.Minute + 30*time.Second), + "Usage": 4*time.Minute + 30*time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } acd.AddEvent(ev4.ID, utils.MapStorage{utils.MetaReq: ev4.Event}) acd.AddEvent(ev5.ID, utils.MapStorage{utils.MetaReq: ev5.Event}) - if v := acd.GetValue(); v != time.Duration(2*time.Minute+45*time.Second) { + if v := acd.GetValue(); v != 2*time.Minute+45*time.Second { t.Errorf("wrong acd value: %+v", v) } acd.RemEvent(ev5.ID) acd.RemEvent(ev4.ID) - if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := acd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong acd value: %+v", v) } acd.RemEvent(ev3.ID) - if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := acd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong acd value: %+v", v) } } @@ -680,7 +680,7 @@ func TestTCDGetStringValue(t *testing.T) { tcd, _ := NewTCD(2, "", []string{}) ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ - "Usage": time.Duration(10 * time.Second), + "Usage": 10 * time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }} if strVal := tcd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { @@ -692,7 +692,7 @@ func TestTCDGetStringValue(t *testing.T) { } ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", Event: map[string]interface{}{ - "Usage": time.Duration(10 * time.Second), + "Usage": 10 * time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3"} @@ -711,13 +711,13 @@ func TestTCDGetStringValue(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } @@ -740,12 +740,12 @@ func TestTCDGetStringValue(t *testing.T) { func TestTCDGetStringValue2(t *testing.T) { tcd, _ := NewTCD(2, "", []string{}) ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} if err := tcd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}); err != nil { t.Error(err) } ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} tcd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) if strVal := tcd.GetStringValue(""); strVal != "3m0s" { t.Errorf("wrong tcd value: %s", strVal) @@ -775,11 +775,11 @@ func TestTCDGetStringValue3(t *testing.T) { } expected.GetStringValue("") ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(3 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 3 * time.Minute}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} if err := tcd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}); err != nil { t.Error(err) } @@ -811,7 +811,7 @@ func TestTCDGetFloat64Value(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second)}} + "Usage": 10 * time.Second}} tcd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) if v := tcd.GetFloat64Value(); v != -1.0 { t.Errorf("wrong tcd value: %f", v) @@ -823,13 +823,13 @@ func TestTCDGetFloat64Value(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } @@ -864,53 +864,53 @@ func TestTCDGetValue(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second)}} + "Usage": 10 * time.Second}} tcd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) - if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := tcd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong tcd value: %+v", v) } ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(5 * time.Second)}} + "Usage": 5 * time.Second}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3"} tcd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) tcd.AddEvent(ev3.ID, utils.MapStorage{utils.MetaReq: ev3.Event}) - if v := tcd.GetValue(); v != time.Duration(15*time.Second) { + if v := tcd.GetValue(); v != 15*time.Second { t.Errorf("wrong tcd value: %+v", v) } tcd.RemEvent(ev.ID) - if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := tcd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong tcd value: %+v", v) } tcd.RemEvent(ev2.ID) - if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := tcd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong tcd value: %+v", v) } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } tcd.AddEvent(ev4.ID, utils.MapStorage{utils.MetaReq: ev4.Event}) tcd.AddEvent(ev5.ID, utils.MapStorage{utils.MetaReq: ev5.Event}) - if v := tcd.GetValue(); v != time.Duration(2*time.Minute+30*time.Second) { + if v := tcd.GetValue(); v != 2*time.Minute+30*time.Second { t.Errorf("wrong tcd value: %+v", v) } tcd.RemEvent(ev5.ID) tcd.RemEvent(ev4.ID) - if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := tcd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong tcd value: %+v", v) } tcd.RemEvent(ev3.ID) - if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := tcd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong tcd value: %+v", v) } } @@ -929,11 +929,11 @@ func TestTCDCompress(t *testing.T) { } expected.GetStringValue("") ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.Usage: time.Duration(3 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 3 * time.Minute}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} tcd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}) tcd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) tcd.AddEvent(ev3.ID, utils.MapStorage{utils.MetaReq: ev3.Event}) @@ -977,11 +977,11 @@ func TestTCDGetCompressFactor(t *testing.T) { tcd, _ := NewTCD(2, "", []string{}) ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{"Usage": time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{"Usage": time.Minute}} ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{utils.Usage: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.Usage: 2 * time.Minute}} tcd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) tcd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) @@ -1548,9 +1548,9 @@ func TestPDDGetStringValue(t *testing.T) { pdd, _ := NewPDD(2, "", []string{}) ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ - utils.Usage: time.Duration(10 * time.Second), + utils.Usage: 10 * time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.PDD: time.Duration(5 * time.Second), + utils.PDD: 5 * time.Second, }} if strVal := pdd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong pdd value: %s", strVal) @@ -1576,14 +1576,14 @@ func TestPDDGetStringValue(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.PDD: time.Duration(10 * time.Second), + utils.PDD: 10 * time.Second, }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - utils.PDD: time.Duration(10 * time.Second), + utils.PDD: 10 * time.Second, }, } pdd.AddEvent(ev4.ID, utils.MapStorage{utils.MetaReq: ev4.Event}) @@ -1609,12 +1609,12 @@ func TestPDDGetStringValue(t *testing.T) { func TestPDDGetStringValue2(t *testing.T) { pdd, _ := NewPDD(2, "", []string{}) ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.PDD: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: 2 * time.Minute}} if err := pdd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}); err != nil { t.Error(err) } ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{utils.PDD: time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: time.Minute}} pdd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) if strVal := pdd.GetStringValue(""); strVal != "1m30s" { t.Errorf("wrong pdd value: %s", strVal) @@ -1644,11 +1644,11 @@ func TestPDDGetStringValue3(t *testing.T) { } expected.GetStringValue("") ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.PDD: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: 2 * time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.PDD: time.Duration(3 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: 3 * time.Minute}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3", - Event: map[string]interface{}{utils.PDD: time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: time.Minute}} if err := pdd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}); err != nil { t.Error(err) } @@ -1680,8 +1680,8 @@ func TestPDDGetFloat64Value(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second)}} + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second}} pdd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) if v := pdd.GetFloat64Value(); v != -1.0 { t.Errorf("wrong pdd value: %v", v) @@ -1693,14 +1693,14 @@ func TestPDDGetFloat64Value(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), - utils.PDD: time.Duration(10 * time.Second), + utils.PDD: 10 * time.Second, }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), }, } @@ -1735,17 +1735,17 @@ func TestPDDGetValue(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(9 * time.Second)}} + "Usage": 10 * time.Second, + utils.PDD: 9 * time.Second}} pdd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) - if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := pdd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong pdd value: %+v", v) } ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(8 * time.Second), - utils.PDD: time.Duration(10 * time.Second)}} + "Usage": 8 * time.Second, + utils.PDD: 10 * time.Second}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3"} if err := pdd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}); err != nil { t.Error(err) @@ -1753,31 +1753,31 @@ func TestPDDGetValue(t *testing.T) { if err := pdd.AddEvent(ev3.ID, utils.MapStorage{utils.MetaReq: ev3.Event}); err == nil || err.Error() != "NOT_FOUND:PDD" { t.Error(err) } - if v := pdd.GetValue(); v != time.Duration(9*time.Second+500*time.Millisecond) { + if v := pdd.GetValue(); v != 9*time.Second+500*time.Millisecond { t.Errorf("wrong pdd value: %+v", v) } if err := pdd.RemEvent(ev.ID); err != nil { t.Error(err) } - if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := pdd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong pdd value: %+v", v) } if err := pdd.RemEvent(ev2.ID); err != nil { t.Error(err) } - if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := pdd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong pdd value: %+v", v) } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.PDD: time.Duration(8 * time.Second), + utils.PDD: 8 * time.Second, }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(4*time.Minute + 30*time.Second), + "Usage": 4*time.Minute + 30*time.Second, "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, } @@ -1787,7 +1787,7 @@ func TestPDDGetValue(t *testing.T) { if err := pdd.AddEvent(ev5.ID, utils.MapStorage{utils.MetaReq: ev5.Event}); err == nil || err.Error() != "NOT_FOUND:PDD" { t.Error(err) } - if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := pdd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong pdd value: %+v", v) } if err := pdd.RemEvent(ev5.ID); err == nil || err.Error() != "NOT_FOUND" { @@ -1796,7 +1796,7 @@ func TestPDDGetValue(t *testing.T) { if err := pdd.RemEvent(ev4.ID); err != nil { t.Error(err) } - if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { + if v := pdd.GetValue(); v != -time.Nanosecond { t.Errorf("wrong pdd value: %+v", v) } } @@ -1815,11 +1815,11 @@ func TestPDDCompress(t *testing.T) { } expected.GetStringValue("") ev1 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.PDD: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: 2 * time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.PDD: time.Duration(3 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: 3 * time.Minute}} ev3 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_3", - Event: map[string]interface{}{utils.PDD: time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: time.Minute}} pdd.AddEvent(ev1.ID, utils.MapStorage{utils.MetaReq: ev1.Event}) pdd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) pdd.AddEvent(ev3.ID, utils.MapStorage{utils.MetaReq: ev3.Event}) @@ -1863,11 +1863,11 @@ func TestPDDGetCompressFactor(t *testing.T) { pdd, _ := NewPDD(2, "", []string{}) ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{utils.PDD: time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: time.Minute}} ev2 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{utils.PDD: time.Duration(1 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: time.Minute}} ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_2", - Event: map[string]interface{}{utils.PDD: time.Duration(2 * time.Minute)}} + Event: map[string]interface{}{utils.PDD: 2 * time.Minute}} pdd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) pdd.AddEvent(ev2.ID, utils.MapStorage{utils.MetaReq: ev2.Event}) @@ -1934,8 +1934,8 @@ func TestDDCGetFloat64Value(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second), + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second, utils.Destination: "1002"}} ddc.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) if v := ddc.GetFloat64Value(); v != -1.0 { @@ -1948,15 +1948,15 @@ func TestDDCGetFloat64Value(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), - utils.PDD: time.Duration(10 * time.Second), + utils.PDD: 10 * time.Second, utils.Destination: "1001", }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), utils.Destination: "1003", }, @@ -2109,8 +2109,8 @@ func TestStatSumGetFloat64Value(t *testing.T) { Event: map[string]interface{}{ "Cost": "20", "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second), + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second, utils.Destination: "1002"}} statSum.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) if v := statSum.GetFloat64Value(); v != -1.0 { @@ -2126,16 +2126,16 @@ func TestStatSumGetFloat64Value(t *testing.T) { ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ "Cost": "20", - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), - utils.PDD: time.Duration(10 * time.Second), + utils.PDD: 10 * time.Second, utils.Destination: "1001", }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ "Cost": "20", - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), utils.Destination: "1003", }, @@ -2389,8 +2389,8 @@ func TestStatAverageGetFloat64Value(t *testing.T) { Event: map[string]interface{}{ "Cost": "20", "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second), + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second, utils.Destination: "1002"}} statAvg.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) if v := statAvg.GetFloat64Value(); v != -1.0 { @@ -2404,16 +2404,16 @@ func TestStatAverageGetFloat64Value(t *testing.T) { ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ "Cost": "30", - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), - utils.PDD: time.Duration(10 * time.Second), + utils.PDD: 10 * time.Second, utils.Destination: "1001", }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ "Cost": "20", - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, "AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC), utils.Destination: "1003", }, @@ -2665,7 +2665,7 @@ func TestStatAverageGetCompressFactor(t *testing.T) { func TestStatDistinctGetFloat64Value(t *testing.T) { statDistinct, _ := NewStatDistinct(2, "~*req.Usage", []string{}) ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", - Event: map[string]interface{}{"Usage": time.Duration(10 * time.Second)}} + Event: map[string]interface{}{"Usage": 10 * time.Second}} statDistinct.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) if v := statDistinct.GetFloat64Value(); v != -1.0 { t.Errorf("wrong statDistinct value: %v", v) @@ -2677,12 +2677,12 @@ func TestStatDistinctGetFloat64Value(t *testing.T) { } ev4 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_4", Event: map[string]interface{}{ - "Usage": time.Duration(1 * time.Minute), + "Usage": time.Minute, }, } ev5 := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_5", Event: map[string]interface{}{ - "Usage": time.Duration(1*time.Minute + 30*time.Second), + "Usage": time.Minute + 30*time.Second, }, } if err := statDistinct.AddEvent(ev4.ID, utils.MapStorage{utils.MetaReq: ev4.Event}); err != nil { @@ -2892,7 +2892,7 @@ func TestACDMarshal(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second)}} + "Usage": 10 * time.Second}} acd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) var nacd StatACD expected := []byte(`{"FilterIDs":[],"Sum":10000000000,"Count":1,"Events":{"EVENT_1":{"Duration":10000000000,"CompressFactor":1}},"MinItems":2}`) @@ -2912,7 +2912,7 @@ func TestTCDMarshal(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second)}} + "Usage": 10 * time.Second}} tcd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) var ntcd StatTCD expected := []byte(`{"FilterIDs":[],"Sum":10000000000,"Count":1,"Events":{"EVENT_1":{"Duration":10000000000,"CompressFactor":1}},"MinItems":2}`) @@ -2972,8 +2972,8 @@ func TestPDDMarshal(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second)}} + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second}} pdd.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) var ntdd StatPDD expected := []byte(`{"FilterIDs":[],"Sum":5000000000,"Count":1,"Events":{"EVENT_1":{"Duration":5000000000,"CompressFactor":1}},"MinItems":2}`) @@ -2993,8 +2993,8 @@ func TestDCCMarshal(t *testing.T) { ev := &utils.CGREvent{Tenant: "cgrates.org", ID: "EVENT_1", Event: map[string]interface{}{ "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second), + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second, utils.Destination: "1002"}} ddc.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) var nddc StatDDC @@ -3016,8 +3016,8 @@ func TestStatSumMarshal(t *testing.T) { Event: map[string]interface{}{ "Cost": "20", "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second), + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second, utils.Destination: "1002"}} statSum.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) var nstatSum StatSum @@ -3039,8 +3039,8 @@ func TestStatAverageMarshal(t *testing.T) { Event: map[string]interface{}{ "Cost": "20", "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second), + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second, utils.Destination: "1002"}} statAvg.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) var nstatAvg StatAverage @@ -3062,8 +3062,8 @@ func TestStatDistrictMarshal(t *testing.T) { Event: map[string]interface{}{ "Cost": "20", "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - "Usage": time.Duration(10 * time.Second), - utils.PDD: time.Duration(5 * time.Second), + "Usage": 10 * time.Second, + utils.PDD: 5 * time.Second, utils.Destination: "1002"}} statDistinct.AddEvent(ev.ID, utils.MapStorage{utils.MetaReq: ev.Event}) var nStatDistinct StatDistinct diff --git a/engine/stats_test.go b/engine/stats_test.go index f47409535..d571ef22d 100644 --- a/engine/stats_test.go +++ b/engine/stats_test.go @@ -28,7 +28,7 @@ import ( var ( cloneExpTimeStats time.Time - expTimeStats = time.Now().Add(time.Duration(20 * time.Minute)) + expTimeStats = time.Now().Add(20 * time.Minute) statService *StatService dmSTS *DataManager sqps = []*StatQueueProfile{ @@ -40,7 +40,7 @@ var ( ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*MetricWithFilters{ { MetricID: "*sum#Usage", @@ -60,7 +60,7 @@ var ( ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*MetricWithFilters{ { MetricID: "*sum#Usage", @@ -80,7 +80,7 @@ var ( ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*MetricWithFilters{ { MetricID: "*sum#Usage", @@ -110,7 +110,7 @@ var ( "UsageInterval": "1s", "PddInterval": "1s", "Weight": "9.0", - utils.Usage: time.Duration(135 * time.Second), + utils.Usage: 135 * time.Second, utils.COST: 123.0, }, }, @@ -127,7 +127,7 @@ var ( "UsageInterval": "1s", "PddInterval": "1s", "Weight": "15.0", - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, }, }, }, @@ -139,7 +139,7 @@ var ( ID: "event3", Event: map[string]interface{}{ "Stats": "StatQueueProfilePrefix", - utils.Usage: time.Duration(30 * time.Second), + utils.Usage: 30 * time.Second, }, }, }, @@ -175,12 +175,12 @@ func TestStatQueuesAddFilters(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.UsageInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, Element: utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + utils.Usage, - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, @@ -202,12 +202,12 @@ func TestStatQueuesAddFilters(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.PddInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, Element: utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + utils.Usage, - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, @@ -376,7 +376,7 @@ func TestStatQueuesV1ProcessEvent(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*MetricWithFilters{ { MetricID: "*sum#Usage", diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index 9e47ea774..631df3560 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -483,10 +483,8 @@ func (ms *MongoStorage) RemoveReverseForPrefix(prefix string) (err error) { return ms.query(func(sctx mongo.SessionContext) error { col := ms.getCol(colName) - if dr, err := col.DeleteMany(sctx, bson.M{}); err != nil { + if _, err := col.DeleteMany(sctx, bson.M{}); err != nil { return err - } else if dr.DeletedCount == 0 { - return utils.ErrNotFound } var keys []string diff --git a/engine/suretax_test.go b/engine/suretax_test.go index 5972c6cbe..963336844 100644 --- a/engine/suretax_test.go +++ b/engine/suretax_test.go @@ -37,7 +37,7 @@ func TestNewSureTaxRequest(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(12) * time.Second, + Usage: 12 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, PreRated: true, } diff --git a/engine/thresholds_test.go b/engine/thresholds_test.go index 53348c01a..fbb9c4d6d 100644 --- a/engine/thresholds_test.go +++ b/engine/thresholds_test.go @@ -51,7 +51,7 @@ var ( ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: 12, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1", "ACT_2"}, @@ -65,7 +65,7 @@ var ( ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: 12, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1", "ACT_2"}, diff --git a/engine/timespans_test.go b/engine/timespans_test.go index b755a4999..cd1c18588 100644 --- a/engine/timespans_test.go +++ b/engine/timespans_test.go @@ -92,7 +92,7 @@ func TestRightHourMargin(t *testing.T) { t.Error("RateInterval not attached correctly") } - if ts.GetDuration() != 29*time.Minute || nts.GetDuration() != 1*time.Minute { + if ts.GetDuration() != 29*time.Minute || nts.GetDuration() != time.Minute { t.Error("Wrong durations.for RateIntervals", ts.GetDuration(), nts.GetDuration()) } if ts.GetDuration().Seconds()+nts.GetDuration().Seconds() != oldDuration.Seconds() { @@ -220,14 +220,14 @@ func TestTimespanGetCost(t *testing.T) { ts1.SetRateInterval( &RateInterval{ Timing: &RITiming{}, - Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1.0, 1 * time.Second, 1 * time.Second}}}, + Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1.0, time.Second, time.Second}}}, }, ) if ts1.CalculateCost() != 600 { t.Error("Expected 10 got ", ts1.Cost) } ts1.RateInterval = nil - ts1.SetRateInterval(&RateInterval{Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1.0, 1 * time.Second, 60 * time.Second}}}}) + ts1.SetRateInterval(&RateInterval{Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1.0, time.Second, 60 * time.Second}}}}) if ts1.CalculateCost() != 10 { t.Error("Expected 6000 got ", ts1.Cost) } @@ -247,12 +247,12 @@ func TestTimespanGetCostIntervals(t *testing.T) { func TestSetRateInterval(t *testing.T) { i1 := &RateInterval{ Timing: &RITiming{}, - Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1.0, 1 * time.Second, 1 * time.Second}}}, + Rating: &RIRate{Rates: RateGroups{&RGRate{0, 1.0, time.Second, time.Second}}}, } ts1 := TimeSpan{RateInterval: i1} i2 := &RateInterval{ Timing: &RITiming{}, - Rating: &RIRate{Rates: RateGroups{&RGRate{0, 2.0, 1 * time.Second, 1 * time.Second}}}, + Rating: &RIRate{Rates: RateGroups{&RGRate{0, 2.0, time.Second, time.Second}}}, } if !ts1.hasBetterRateIntervalThan(i2) { ts1.SetRateInterval(i2) @@ -273,7 +273,7 @@ func TestTimespanSplitGroupedRates(t *testing.T) { EndTime: "17:59:00", }, Rating: &RIRate{ - Rates: RateGroups{&RGRate{0, 2, 1 * time.Second, 1 * time.Second}, &RGRate{900 * time.Second, 1, 1 * time.Second, 1 * time.Second}}, + Rates: RateGroups{&RGRate{0, 2, time.Second, time.Second}, &RGRate{900 * time.Second, 1, time.Second, time.Second}}, }, } t1 := time.Date(2012, time.February, 3, 17, 30, 0, 0, time.UTC) @@ -353,7 +353,7 @@ func TestTimespanSplitGroupedRatesIncrements(t *testing.T) { t.Error("Wrong costs: ", c1, c2) } - if ts.GetDuration().Seconds() != 0.5*60 || nts.GetDuration().Seconds() != 1*60 { + if ts.GetDuration().Seconds() != 0.5*60 || nts.GetDuration().Seconds() != 60 { t.Error("Wrong durations.for RateIntervals", ts.GetDuration().Seconds(), nts.GetDuration().Seconds()) } if ts.GetDuration()+nts.GetDuration() != oldDuration+30*time.Second { @@ -367,7 +367,7 @@ func TestTimespanSplitRightHourMarginBeforeGroup(t *testing.T) { EndTime: "17:00:30", }, Rating: &RIRate{ - Rates: RateGroups{&RGRate{0, 2, 1 * time.Second, 1 * time.Second}, &RGRate{60 * time.Second, 1, 60 * time.Second, 1 * time.Second}}, + Rates: RateGroups{&RGRate{0, 2, time.Second, time.Second}, &RGRate{60 * time.Second, 1, 60 * time.Second, time.Second}}, }, } t1 := time.Date(2012, time.February, 3, 17, 00, 0, 0, time.UTC) @@ -404,7 +404,7 @@ func TestTimespanSplitGroupSecondSplit(t *testing.T) { EndTime: "17:03:30", }, Rating: &RIRate{ - Rates: RateGroups{&RGRate{0, 2, 1 * time.Second, 1 * time.Second}, &RGRate{60 * time.Second, 1, 1 * time.Second, 1 * time.Second}}}, + Rates: RateGroups{&RGRate{0, 2, time.Second, time.Second}, &RGRate{60 * time.Second, 1, time.Second, time.Second}}}, } t1 := time.Date(2012, time.February, 3, 17, 00, 0, 0, time.UTC) t2 := time.Date(2012, time.February, 3, 17, 04, 0, 0, time.UTC) @@ -481,7 +481,7 @@ func TestTimespanSplitMultipleGroup(t *testing.T) { EndTime: "17:05:00", }, Rating: &RIRate{ - Rates: RateGroups{&RGRate{0, 2, 1 * time.Second, 1 * time.Second}, &RGRate{60 * time.Second, 1, 1 * time.Second, 1 * time.Second}, &RGRate{180 * time.Second, 1, 1 * time.Second, 1 * time.Second}}}, + Rates: RateGroups{&RGRate{0, 2, time.Second, time.Second}, &RGRate{60 * time.Second, 1, time.Second, time.Second}, &RGRate{180 * time.Second, 1, time.Second, time.Second}}}, } t1 := time.Date(2012, time.February, 3, 17, 00, 0, 0, time.UTC) t2 := time.Date(2012, time.February, 3, 17, 04, 0, 0, time.UTC) @@ -1709,7 +1709,7 @@ func TestCompressDecompress(t *testing.T) { TimeStart: time.Date(2015, 1, 9, 16, 18, 0, 0, time.UTC), TimeEnd: time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC), Cost: 1.2, - DurationIndex: 1 * time.Minute, + DurationIndex: time.Minute, }, &TimeSpan{ TimeStart: time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC), @@ -1746,7 +1746,7 @@ func TestCompressDecompress(t *testing.T) { if len(tss) != 4 || !tss[0].TimeStart.Equal(time.Date(2015, 1, 9, 16, 18, 0, 0, time.UTC)) || !tss[0].TimeEnd.Equal(time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC)) || - tss[0].DurationIndex != 1*time.Minute || + tss[0].DurationIndex != time.Minute || tss[0].CompressFactor != 1 || tss[0].Cost != 1.2 || !tss[1].TimeStart.Equal(time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC)) || @@ -1778,7 +1778,7 @@ func TestDifferentCompressDecompress(t *testing.T) { TimeEnd: time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC), RateInterval: &RateInterval{Weight: 1}, Cost: 1.2, - DurationIndex: 1 * time.Minute, + DurationIndex: time.Minute, }, &TimeSpan{ TimeStart: time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC), @@ -1806,7 +1806,7 @@ func TestDifferentCompressDecompress(t *testing.T) { if len(tss) != 3 || !tss[0].TimeStart.Equal(time.Date(2015, 1, 9, 16, 18, 0, 0, time.UTC)) || !tss[0].TimeEnd.Equal(time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC)) || - tss[0].DurationIndex != 1*time.Minute || + tss[0].DurationIndex != time.Minute || tss[0].Cost != 1.2 || !tss[1].TimeStart.Equal(time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC)) || !tss[1].TimeEnd.Equal(time.Date(2015, 1, 9, 16, 20, 0, 0, time.UTC)) || @@ -1825,7 +1825,7 @@ func TestDifferentCompressDecompress(t *testing.T) { if len(tss) != 4 || !tss[0].TimeStart.Equal(time.Date(2015, 1, 9, 16, 18, 0, 0, time.UTC)) || !tss[0].TimeEnd.Equal(time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC)) || - tss[0].DurationIndex != 1*time.Minute || + tss[0].DurationIndex != time.Minute || tss[0].CompressFactor != 1 || tss[0].Cost != 1.2 || !tss[1].TimeStart.Equal(time.Date(2015, 1, 9, 16, 19, 0, 0, time.UTC)) || @@ -1867,7 +1867,7 @@ func TestMerge(t *testing.T) { }, }, Cost: 3, - DurationIndex: 1 * time.Minute, + DurationIndex: time.Minute, Increments: Increments{ &Increment{ Duration: time.Minute, @@ -1978,13 +1978,13 @@ func TestIncrementClone(t *testing.T) { t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(eOut), utils.ToJSON(clone)) } incr = &Increment{ - Duration: time.Duration(10), + Duration: 10, Cost: 0.7, CompressFactor: 10, BalanceInfo: &DebitInfo{AccountID: "AccountID_test"}, } eOut = &Increment{ - Duration: time.Duration(10), + Duration: 10, Cost: 0.7, CompressFactor: 10, BalanceInfo: &DebitInfo{AccountID: "AccountID_test"}, diff --git a/engine/z_actions_it_test.go b/engine/z_actions_it_test.go index 849583d4d..fdd5b26ea 100644 --- a/engine/z_actions_it_test.go +++ b/engine/z_actions_it_test.go @@ -345,7 +345,7 @@ func testActionsitThresholdCDrLog(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_TH_CDRLOG"}, @@ -386,9 +386,9 @@ func testActionsitThresholdCDrLog(t *testing.T) { utils.Subject: "th_acc", utils.Destination: "+4986517174963", utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), - utils.PDD: time.Duration(0) * time.Second, + utils.PDD: 0 * time.Second, utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.ROUTE: "SUPPL1", utils.COST: -1.0, }, @@ -493,7 +493,7 @@ func testActionsitCDRAccount(t *testing.T) { Subject: acnt, Destination: "1002", AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - Usage: time.Duration(2) * time.Minute, + Usage: 2 * time.Minute, CostDetails: &EventCost{ CGRID: utils.UUIDSha1Prefix(), RunID: utils.MetaDefault, @@ -565,7 +565,7 @@ func testActionsitThresholdCgrRpcAction(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_TH_CGRRPC"}, @@ -630,7 +630,7 @@ func testActionsitThresholdPostEvent(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_TH_POSTEVENT"}, @@ -664,9 +664,9 @@ func testActionsitThresholdPostEvent(t *testing.T) { utils.RequestType: utils.META_RATED, utils.Tenant: "cgrates.org", utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), - utils.PDD: time.Duration(0) * time.Second, + utils.PDD: 0 * time.Second, utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Second, + utils.Usage: 10 * time.Second, utils.ROUTE: "SUPPL1", utils.COST: -1.0, }, @@ -745,7 +745,7 @@ func testActionsitSetSDestinations(t *testing.T) { Tenant: "cgrates.org", ID: "DistinctMetricProfile", QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*MetricWithFilters{{ MetricID: utils.MetaDDC, }}, @@ -770,7 +770,7 @@ func testActionsitSetSDestinations(t *testing.T) { ID: "event1", Event: map[string]interface{}{ utils.Destination: "333", - utils.Usage: time.Duration(6 * time.Second), + utils.Usage: 6 * time.Second, }, }, }, @@ -788,7 +788,7 @@ func testActionsitSetSDestinations(t *testing.T) { ID: "event2", Event: map[string]interface{}{ utils.Destination: "777", - utils.Usage: time.Duration(6 * time.Second), + utils.Usage: 6 * time.Second, }, }, }, @@ -880,7 +880,7 @@ func testActionsitresetAccountCDR(t *testing.T) { Subject: account, Destination: "1002", AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - Usage: time.Duration(2) * time.Minute, + Usage: 2 * time.Minute, CostDetails: &EventCost{ CGRID: utils.UUIDSha1Prefix(), RunID: utils.MetaDefault, diff --git a/engine/z_attributes_test.go b/engine/z_attributes_test.go index c2a8d228e..79578b7d9 100644 --- a/engine/z_attributes_test.go +++ b/engine/z_attributes_test.go @@ -28,7 +28,7 @@ import ( ) var ( - expTimeAttributes = time.Now().Add(time.Duration(20 * time.Minute)) + expTimeAttributes = time.Now().Add(20 * time.Minute) attrService *AttributeService dmAtr *DataManager attrEvs = []*AttrArgsProcessEvent{ @@ -182,7 +182,7 @@ func TestAttributeAddFilters(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.UsageInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, diff --git a/engine/z_filterindexer_it_test.go b/engine/z_filterindexer_it_test.go index 2b1535b79..e27aff3e6 100644 --- a/engine/z_filterindexer_it_test.go +++ b/engine/z_filterindexer_it_test.go @@ -249,14 +249,13 @@ func testITTestThresholdFilterIndexes(t *testing.T) { if err := dataManager.SetFilter(fp, true); err != nil { t.Error(err) } - timeMinSleep := time.Duration(0 * time.Second) th := &ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{"Filter1"}, MaxHits: 12, - MinSleep: timeMinSleep, + MinSleep: 0, Blocker: true, Weight: 1.4, ActionIDs: []string{}, @@ -267,7 +266,7 @@ func testITTestThresholdFilterIndexes(t *testing.T) { ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{"Filter1"}, MaxHits: 12, - MinSleep: timeMinSleep, + MinSleep: 0, Blocker: true, Weight: 1.4, ActionIDs: []string{}, @@ -825,7 +824,7 @@ func testITTestThresholdInlineFilterIndexing(t *testing.T) { ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{"Filter1"}, MaxHits: 12, - MinSleep: time.Duration(0 * time.Second), + MinSleep: 0, Blocker: true, Weight: 1.4, ActionIDs: []string{}, @@ -856,7 +855,7 @@ func testITTestThresholdInlineFilterIndexing(t *testing.T) { ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{"Filter1", "*string:~*req.Account:1001"}, MaxHits: 12, - MinSleep: time.Duration(0 * time.Second), + MinSleep: 0, Blocker: true, Weight: 1.4, ActionIDs: []string{}, @@ -1002,7 +1001,7 @@ func testITTestIndexingWithEmptyFltrID(t *testing.T) { ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{}, MaxHits: 12, - MinSleep: time.Duration(0 * time.Second), + MinSleep: 0, Blocker: true, Weight: 1.4, ActionIDs: []string{}, @@ -1013,7 +1012,7 @@ func testITTestIndexingWithEmptyFltrID(t *testing.T) { ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{}, MaxHits: 12, - MinSleep: time.Duration(0 * time.Second), + MinSleep: 0, Blocker: true, Weight: 1.4, ActionIDs: []string{}, @@ -1283,8 +1282,8 @@ func testITIndexRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, }, Blocker: false, @@ -1296,8 +1295,8 @@ func testITIndexRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, Blocker: false, @@ -1344,8 +1343,8 @@ func testITIndexRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, }, Blocker: false, @@ -1357,8 +1356,8 @@ func testITIndexRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, Blocker: false, @@ -1370,8 +1369,8 @@ func testITIndexRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, Blocker: false, @@ -1419,8 +1418,8 @@ func testITIndexRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, }, Blocker: false, @@ -1432,8 +1431,8 @@ func testITIndexRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.6, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, Blocker: false, diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go index d52ca8afe..f39f73d0a 100644 --- a/engine/z_onstor_it_test.go +++ b/engine/z_onstor_it_test.go @@ -1184,7 +1184,7 @@ func testOnStorITResourceProfile(t *testing.T) { ExpiryTime: time.Date(2015, 7, 3, 13, 43, 0, 0, time.UTC)}, Limit: 1, ThresholdIDs: []string{"TEST_ACTIONS"}, - UsageTTL: time.Duration(3 * time.Nanosecond), + UsageTTL: 3 * time.Nanosecond, } if _, rcvErr := onStor.GetResourceProfile(rL.Tenant, rL.ID, true, false, utils.NonTransactional); rcvErr != utils.ErrNotFound { @@ -1449,7 +1449,7 @@ func testOnStorITStatQueueProfile(t *testing.T) { ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{"FLTR_1"}, QueueLength: 2, - TTL: time.Duration(0 * time.Second), + TTL: 0, Stored: true, ThresholdIDs: []string{"Thresh1"}, } @@ -1595,7 +1595,7 @@ func testOnStorITThresholdProfile(t *testing.T) { ActivationInterval: &utils.ActivationInterval{}, FilterIDs: []string{"TestFilter2"}, MaxHits: 12, - MinSleep: time.Duration(0 * time.Second), + MinSleep: 0, Blocker: true, Weight: 1.4, ActionIDs: []string{"Action1"}, @@ -2177,8 +2177,8 @@ func testOnStorITRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, }, Blocker: false, @@ -2190,8 +2190,8 @@ func testOnStorITRateProfile(t *testing.T) { IntervalRates: []*IntervalRate{ { Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, Blocker: false, diff --git a/engine/z_poster_it_test.go b/engine/z_poster_it_test.go index 4d205fbd1..1d6836777 100644 --- a/engine/z_poster_it_test.go +++ b/engine/z_poster_it_test.go @@ -63,11 +63,11 @@ type TestContent struct { } func TestHttpJsonPoster(t *testing.T) { - SetFailedPostCacheTTL(1 * time.Millisecond) + SetFailedPostCacheTTL(time.Millisecond) config.CgrConfig().GeneralCfg().FailedPostsDir = "/tmp" content := &TestContent{Var1: "Val1", Var2: "Val2"} jsn, _ := json.Marshal(content) - pstr, err := NewHTTPPoster(time.Duration(2*time.Second), "http://localhost:8080/invalid", utils.CONTENT_JSON, 3) + pstr, err := NewHTTPPoster(2*time.Second, "http://localhost:8080/invalid", utils.CONTENT_JSON, 3) if err != nil { t.Error(err) } @@ -95,12 +95,12 @@ func TestHttpJsonPoster(t *testing.T) { } func TestHttpBytesPoster(t *testing.T) { - SetFailedPostCacheTTL(1 * time.Millisecond) + SetFailedPostCacheTTL(time.Millisecond) config.CgrConfig().GeneralCfg().FailedPostsDir = "/tmp" content := []byte(`Test Test2 `) - pstr, err := NewHTTPPoster(time.Duration(2*time.Second), "http://localhost:8080/invalid", utils.CONTENT_TEXT, 3) + pstr, err := NewHTTPPoster(2*time.Second, "http://localhost:8080/invalid", utils.CONTENT_TEXT, 3) if err != nil { t.Error(err) } @@ -309,7 +309,7 @@ func TestAMQPv1Poster(t *testing.T) { t.Fatal("Creating AMQP session:", err) } - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), time.Second) // Create a receiver receiver, err := session.NewReceiver( @@ -319,7 +319,7 @@ func TestAMQPv1Poster(t *testing.T) { t.Fatal("Creating receiver link:", err) } defer func() { - ctx, cancel := context.WithTimeout(ctx, 1*time.Second) + ctx, cancel := context.WithTimeout(ctx, time.Second) receiver.Close(ctx) cancel() }() diff --git a/engine/z_resources_test.go b/engine/z_resources_test.go index 492de35ad..0b5c779d9 100644 --- a/engine/z_resources_test.go +++ b/engine/z_resources_test.go @@ -30,7 +30,7 @@ var ( r1, r2 *Resource ru1, ru2 *ResourceUsage rs Resources - timeDurationExample = time.Duration(10) * time.Second + timeDurationExample = 10 * time.Second resService *ResourceService dmRES *DataManager resprf = []*ResourceProfile{ @@ -41,7 +41,7 @@ var ( ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(10) * time.Second, + UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", Weight: 20.00, @@ -54,7 +54,7 @@ var ( ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(10) * time.Second, + UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", Weight: 20.00, @@ -67,7 +67,7 @@ var ( ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(10) * time.Second, + UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", Weight: 20.00, @@ -108,7 +108,7 @@ var ( "UsageInterval": "1s", "PddInterval": "1s", utils.Weight: "20.0", - utils.Usage: time.Duration(135 * time.Second), + utils.Usage: 135 * time.Second, utils.COST: 123.0, }, }, @@ -123,7 +123,7 @@ var ( "UsageInterval": "1s", "PddInterval": "1s", utils.Weight: "15.0", - utils.Usage: time.Duration(45 * time.Second), + utils.Usage: 45 * time.Second, }, }, }, @@ -133,7 +133,7 @@ var ( ID: "event3", Event: map[string]interface{}{ "Resources": "ResourceProfilePrefix", - utils.Usage: time.Duration(30 * time.Second), + utils.Usage: 30 * time.Second, }, }, }, @@ -164,13 +164,13 @@ func TestResourceRecordUsage1(t *testing.T) { FilterIDs: []string{"FLTR_RES_RL1"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 3, 13, 43, 0, 1, time.UTC), - ExpiryTime: time.Date(2014, 7, 3, 13, 43, 0, 1, time.UTC).Add(time.Duration(1 * time.Millisecond)), + ExpiryTime: time.Date(2014, 7, 3, 13, 43, 0, 1, time.UTC).Add(time.Millisecond), }, Weight: 100, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, - UsageTTL: time.Duration(1 * time.Millisecond), + UsageTTL: time.Millisecond, AllocationMessage: "ALLOC", }, Usages: map[string]*ResourceUsage{ @@ -239,7 +239,7 @@ func TestResourceSort(t *testing.T) { Weight: 50, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, - UsageTTL: time.Duration(1 * time.Millisecond), + UsageTTL: time.Millisecond, }, // AllocationMessage: "ALLOC2", Usages: map[string]*ResourceUsage{ @@ -290,8 +290,8 @@ func TestResourceRecordUsages(t *testing.T) { func TestResourceAllocateResource(t *testing.T) { rs.clearUsage(ru1.ID) rs.clearUsage(ru2.ID) - ru1.ExpiryTime = time.Now().Add(time.Duration(1 * time.Second)) - ru2.ExpiryTime = time.Now().Add(time.Duration(1 * time.Second)) + ru1.ExpiryTime = time.Now().Add(time.Second) + ru2.ExpiryTime = time.Now().Add(time.Second) if alcMessage, err := rs.allocateResource(ru1, false); err != nil { t.Error(err.Error()) } else { @@ -343,7 +343,7 @@ func TestRSCacheSetGet(t *testing.T) { Weight: 50, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, - UsageTTL: time.Duration(1 * time.Millisecond), + UsageTTL: time.Millisecond, }, Usages: map[string]*ResourceUsage{ "RU2": { @@ -425,12 +425,12 @@ func TestResourceAddFilters(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.UsageInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, Element: utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + utils.Usage, - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, @@ -452,12 +452,12 @@ func TestResourceAddFilters(t *testing.T) { { Type: utils.MetaGreaterOrEqual, Element: "~*req.PddInterval", - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, Element: utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + utils.Usage, - Values: []string{(1 * time.Second).String()}, + Values: []string{(time.Second).String()}, }, { Type: utils.MetaGreaterOrEqual, @@ -542,7 +542,7 @@ func TestResourceMatchingResourcesForEvent(t *testing.T) { //UsageTTL 0 in ResourceProfile and give 10s duration func TestResourceUsageTTLCase1(t *testing.T) { - resprf[0].UsageTTL = time.Duration(0) + resprf[0].UsageTTL = 0 resourceTest[0].rPrf = resprf[0] resourceTest[0].ttl = &timeDurationExample if err := dmRES.SetResourceProfile(resprf[0], true); err != nil { @@ -569,7 +569,7 @@ func TestResourceUsageTTLCase1(t *testing.T) { //UsageTTL 5s in ResourceProfile and give nil duration func TestResourceUsageTTLCase2(t *testing.T) { - resprf[0].UsageTTL = time.Duration(0) + resprf[0].UsageTTL = 0 resourceTest[0].rPrf = resprf[0] resourceTest[0].ttl = &resprf[0].UsageTTL if err := dmRES.SetResourceProfile(resprf[0], true); err != nil { @@ -596,7 +596,7 @@ func TestResourceUsageTTLCase2(t *testing.T) { //UsageTTL 5s in ResourceProfile and give 0 duration func TestResourceUsageTTLCase3(t *testing.T) { - resprf[0].UsageTTL = time.Duration(0) + resprf[0].UsageTTL = 0 resourceTest[0].rPrf = resprf[0] resourceTest[0].ttl = nil if err := dmRES.SetResourceProfile(resprf[0], true); err != nil { @@ -606,7 +606,7 @@ func TestResourceUsageTTLCase3(t *testing.T) { t.Error(err) } mres, err := resService.matchingResourcesForEvent(resEvs[0].Tenant, resEvs[0], - "TestResourceUsageTTLCase3", utils.DurationPointer(time.Duration(0))) + "TestResourceUsageTTLCase3", utils.DurationPointer(0)) if err != nil { t.Errorf("Error: %+v", err) } @@ -623,7 +623,7 @@ func TestResourceUsageTTLCase3(t *testing.T) { //UsageTTL 5s in ResourceProfile and give 10s duration func TestResourceUsageTTLCase4(t *testing.T) { - resprf[0].UsageTTL = time.Duration(5) + resprf[0].UsageTTL = 5 resourceTest[0].rPrf = resprf[0] resourceTest[0].ttl = &timeDurationExample if err := dmRES.SetResourceProfile(resprf[0], true); err != nil { @@ -747,7 +747,7 @@ func TestResourceCaching(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(-1), + UsageTTL: -1, Limit: 10.00, AllocationMessage: "AllocationMessage", Weight: 20.00, diff --git a/engine/z_storage_cdrs_it_test.go b/engine/z_storage_cdrs_it_test.go index c5f218e24..8f93d278b 100644 --- a/engine/z_storage_cdrs_it_test.go +++ b/engine/z_storage_cdrs_it_test.go @@ -92,7 +92,7 @@ func testSetCDR(cfg *config.CGRConfig) error { Destination: "1007", SetupTime: time.Date(2015, 12, 12, 14, 52, 0, 0, time.UTC), AnswerTime: time.Date(2015, 12, 12, 14, 52, 20, 0, time.UTC), - Usage: time.Duration(35) * time.Second, + Usage: 35 * time.Second, ExtraFields: map[string]string{"ExtraHeader1": "ExtraVal1", "ExtraHeader2": "ExtraVal2"}, Cost: -1, } @@ -119,7 +119,7 @@ func testSetCDR(cfg *config.CGRConfig) error { Destination: "1007", SetupTime: time.Date(2015, 12, 12, 14, 52, 0, 0, time.UTC), AnswerTime: time.Date(2015, 12, 12, 14, 52, 20, 0, time.UTC), - Usage: time.Duration(35) * time.Second, + Usage: 35 * time.Second, ExtraFields: map[string]string{"ExtraHeader1": "ExtraVal1", "ExtraHeader2": "ExtraVal2"}, CostSource: "testSetCDRs", Cost: 0.17, diff --git a/ers/ers_test.go b/ers/ers_test.go index a683ad07a..38c14d31e 100644 --- a/ers/ers_test.go +++ b/ers/ers_test.go @@ -21,7 +21,6 @@ package ers import ( "reflect" "testing" - "time" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" @@ -55,7 +54,7 @@ func TestERsAddReader(t *testing.T) { reader := cfg.ERsCfg().Readers[0] reader.Type = utils.MetaFileCSV reader.ID = "file_reader" - reader.RunDelay = time.Duration(0) + reader.RunDelay = 0 cfg.ERsCfg().Readers = append(cfg.ERsCfg().Readers, reader) if len(cfg.ERsCfg().Readers) != 2 { t.Errorf("Expecting: <2>, received: <%+v>", len(cfg.ERsCfg().Readers)) diff --git a/ers/filecsv_it_test.go b/ers/filecsv_it_test.go index 25c2d2fe1..d86f497ed 100644 --- a/ers/filecsv_it_test.go +++ b/ers/filecsv_it_test.go @@ -309,7 +309,7 @@ func testCsvITAnalyzeFilteredCDR(t *testing.T) { } func testCsvITProcessedFiles(t *testing.T) { - time.Sleep(time.Duration(1 * time.Second)) + time.Sleep(time.Second) if outContent1, err := ioutil.ReadFile("/tmp/ers/out/file1.csv"); err != nil { t.Error(err) } else if fileContent1 != string(outContent1) { diff --git a/general_tests/a1_it_test.go b/general_tests/a1_it_test.go index 293ca2e53..e5d816f76 100644 --- a/general_tests/a1_it_test.go +++ b/general_tests/a1_it_test.go @@ -116,7 +116,7 @@ func testA1itLoadTPFromFolder(t *testing.T) { } else if reply != utils.OK { t.Error(reply) } - time.Sleep(time.Duration(100 * time.Millisecond)) + time.Sleep(100 * time.Millisecond) tStart := time.Date(2017, 3, 3, 10, 39, 33, 0, time.UTC) tEnd := time.Date(2017, 3, 3, 10, 39, 33, 10240, time.UTC) cd := &engine.CallDescriptorWithOpts{ @@ -252,7 +252,7 @@ func testA1itDataSession1(t *testing.T) { }, } - usage = time.Duration(2097152) + usage = 2097152 var updateRpl *sessions.V1UpdateSessionReply if err := a1rpc.Call(utils.SessionSv1UpdateSession, updateArgs, &updateRpl); err != nil { t.Error(err) @@ -261,7 +261,7 @@ func testA1itDataSession1(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", usage, updateRpl.MaxUsage) } - usage = time.Duration(1 * time.Minute) + usage = time.Minute termArgs := &sessions.V1TerminateSessionArgs{ TerminateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -298,7 +298,7 @@ func testA1itDataSession1(t *testing.T) { t.Errorf("Received reply: %s", rpl) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(20 * time.Millisecond) var cdrs []*engine.ExternalCDR req := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}} diff --git a/general_tests/accounts_it_test.go b/general_tests/accounts_it_test.go index c15706b15..37e3cdb0a 100644 --- a/general_tests/accounts_it_test.go +++ b/general_tests/accounts_it_test.go @@ -257,7 +257,7 @@ func testV1AccSendToThreshold(t *testing.T) { FilterIDs: []string{"*string:~*opts.*eventType:AccountUpdate", "*string:~*asm.ID:testAccThreshold"}, MaxHits: -1, - MinSleep: time.Duration(1 * time.Second), + MinSleep: time.Second, Weight: 20.0, Async: true, ActionIDs: []string{"DISABLE_LOG"}, diff --git a/general_tests/attributes_it_test.go b/general_tests/attributes_it_test.go index 5236e1158..cc0716510 100644 --- a/general_tests/attributes_it_test.go +++ b/general_tests/attributes_it_test.go @@ -362,7 +362,7 @@ func testAttributeSProcessEventWithStat(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 10.0, }, }, @@ -381,7 +381,7 @@ func testAttributeSProcessEventWithStat(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 10.5, }, } @@ -563,7 +563,7 @@ func testAttributeSProcessEventWithResource(t *testing.T) { rlsConfig := &engine.ResourceProfile{ Tenant: "cgrates.org", ID: "ResTest", - UsageTTL: time.Duration(1) * time.Minute, + UsageTTL: time.Minute, Limit: 10, AllocationMessage: "MessageAllocation", Stored: true, diff --git a/general_tests/auth_test.go b/general_tests/auth_test.go index fc1c6f9b9..84df7cd34 100644 --- a/general_tests/auth_test.go +++ b/general_tests/auth_test.go @@ -150,7 +150,7 @@ func TestAuthPostpaidFallbackDest(t *testing.T) { var maxSessionTime time.Duration if err = rsponder.GetMaxSessionTime(&engine.CallDescriptorWithOpts{CallDescriptor: cd}, &maxSessionTime); err != nil { t.Error(err) - } else if maxSessionTime != time.Duration(0) { + } else if maxSessionTime != 0 { t.Error("Unexpected maxSessionTime received: ", maxSessionTime) } } @@ -167,7 +167,7 @@ func TestAuthPostpaidWithDestination(t *testing.T) { var maxSessionTime time.Duration if err := rsponder.GetMaxSessionTime(&engine.CallDescriptorWithOpts{CallDescriptor: cd}, &maxSessionTime); err != nil { t.Error(err) - } else if maxSessionTime != time.Duration(0) { + } else if maxSessionTime != 0 { t.Error("Unexpected maxSessionTime received: ", maxSessionTime) } } diff --git a/general_tests/cdrs_exp_it_test.go b/general_tests/cdrs_exp_it_test.go index d0f4aa0bf..0807b6942 100644 --- a/general_tests/cdrs_exp_it_test.go +++ b/general_tests/cdrs_exp_it_test.go @@ -274,7 +274,7 @@ func testCDRsExpHTTP(t *testing.T) { if !reflect.DeepEqual(cdrsExpEvExp, rcvCDR) { t.Errorf("Expected %s received %s", utils.ToJSON(cdrsExpEvExp), utils.ToJSON(rcvCDR)) } - case <-time.After(time.Duration(100 * time.Millisecond)): + case <-time.After(100 * time.Millisecond): t.Error("No message received from RabbitMQ") } } @@ -299,7 +299,7 @@ func testCDRsExpAMQP(t *testing.T) { if !reflect.DeepEqual(cdrsExpEvExp, rcvCDR) { t.Errorf("Expected %s received %s", utils.ToJSON(cdrsExpEvExp), utils.ToJSON(rcvCDR)) } - case <-time.After(time.Duration(100 * time.Millisecond)): + case <-time.After(100 * time.Millisecond): t.Error("No message received from RabbitMQ") } } diff --git a/general_tests/cdrs_it_test.go b/general_tests/cdrs_it_test.go index 7d99e7c94..3e46b050d 100644 --- a/general_tests/cdrs_it_test.go +++ b/general_tests/cdrs_it_test.go @@ -173,7 +173,7 @@ func testV2CDRsProcessCDR(t *testing.T) { utils.Subject: "ANY2CNT", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, @@ -187,7 +187,7 @@ func testV2CDRsProcessCDR(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsGetCdrs(t *testing.T) { @@ -246,7 +246,7 @@ func testV2CDRsProcessCDR2(t *testing.T) { utils.Subject: "ANY2CNT", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, @@ -260,7 +260,7 @@ func testV2CDRsProcessCDR2(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsGetCdrs2(t *testing.T) { @@ -321,7 +321,7 @@ func testV2CDRsProcessCDR3(t *testing.T) { utils.Subject: "ANY2CNT", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, @@ -335,7 +335,7 @@ func testV2CDRsProcessCDR3(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsGetCdrs3(t *testing.T) { @@ -399,7 +399,7 @@ func testV2CDRsProcessCDR4(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsGetCdrs4(t *testing.T) { @@ -591,7 +591,7 @@ func testV2CDRsProcessCDR5(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsGetStats1(t *testing.T) { @@ -660,7 +660,7 @@ func testV2CDRsProcessCDR6(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsGetStats2(t *testing.T) { @@ -721,7 +721,7 @@ func testV2CDRsProcessCDR7(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated } func testV2CDRsGetCdrs7(t *testing.T) { diff --git a/general_tests/cdrs_onlexp_it_test.go b/general_tests/cdrs_onlexp_it_test.go index ec12b6408..c206f757c 100644 --- a/general_tests/cdrs_onlexp_it_test.go +++ b/general_tests/cdrs_onlexp_it_test.go @@ -166,7 +166,7 @@ func testCDRsOnExpAMQPQueuesCreation(t *testing.T) { func testCDRsOnExpInitMasterRPC(t *testing.T) { var err error cdrsMasterRpc, err = rpcclient.NewRPCClient(utils.TCP, cdrsMasterCfg.ListenCfg().RPCJSONListen, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) + time.Second, 2*time.Second, rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal("Could not connect to rater: ", err.Error()) } @@ -209,7 +209,7 @@ func testCDRsOnExpDisableOnlineExport(t *testing.T) { Destination: "1002", SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, RunID: utils.MetaDefault, Cost: 1.201, @@ -257,7 +257,7 @@ func testCDRsOnExpHttpCdrReplication(t *testing.T) { Destination: "1002", SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, RunID: utils.MetaDefault, Cost: 1.201, @@ -275,7 +275,7 @@ func testCDRsOnExpHttpCdrReplication(t *testing.T) { } time.Sleep(time.Duration(*waitRater) * time.Millisecond) cdrsSlaveRpc, err := rpcclient.NewRPCClient(utils.TCP, "127.0.0.1:12012", false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) + time.Second, 2*time.Second, rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal("Could not connect to rater: ", err.Error()) } @@ -337,7 +337,7 @@ func testCDRsOnExpAMQPReplication(t *testing.T) { if rcvCDR[utils.CGRID] != httpCGRID { t.Errorf("Unexpected CDR received: %+v", rcvCDR) } - case <-time.After(time.Duration(100 * time.Millisecond)): + case <-time.After(100 * time.Millisecond): t.Error("No message received from RabbitMQ") } if msgs, err = ch.Consume("queue1", "consumer", true, false, false, false, nil); err != nil { @@ -353,7 +353,7 @@ func testCDRsOnExpAMQPReplication(t *testing.T) { if rcvCDR[utils.CGRID] != httpCGRID { t.Errorf("Unexpected CDR received: %+v", rcvCDR) } - case <-time.After(time.Duration(100 * time.Millisecond)): + case <-time.After(100 * time.Millisecond): t.Error("No message received from RabbitMQ") } conn.Close() @@ -377,7 +377,7 @@ func testCDRsOnExpAMQPReplication(t *testing.T) { Destination: "1002", SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), - Usage: time.Duration(10) * time.Second, + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, RunID: utils.MetaDefault, Cost: 1.201, @@ -539,7 +539,7 @@ func testCdrsHttpCdrReplication2(t *testing.T) { ToR: utils.VOICE, OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_PSEUDOPREPAID, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), - Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} + Usage: 10 * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} cdrs = append(cdrs, cdr) } var reply string diff --git a/general_tests/cdrs_post_failover_it_test.go b/general_tests/cdrs_post_failover_it_test.go index 91eefc3b4..f64146eed 100644 --- a/general_tests/cdrs_post_failover_it_test.go +++ b/general_tests/cdrs_post_failover_it_test.go @@ -148,7 +148,7 @@ func testCDRsPostFailoverProcessCDR(t *testing.T) { utils.Subject: "ANY2CNT", utils.Destination: "+4986517174963", utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), - utils.Usage: time.Duration(1) * time.Minute, + utils.Usage: time.Minute, "field_extr1": "val_extr1", "fieldextr2": "valextr2", }, @@ -179,7 +179,7 @@ func testCDRsPostFailoverProcessCDR(t *testing.T) { } func testCDRsPostFailoverToFile(t *testing.T) { - time.Sleep(time.Duration(2 * time.Second)) + time.Sleep(2 * time.Second) filesInDir, _ := ioutil.ReadDir(cdrsPostFailCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) == 0 { t.Fatalf("No files in directory: %s", cdrsPostFailCfg.GeneralCfg().FailedPostsDir) diff --git a/general_tests/data_it_test.go b/general_tests/data_it_test.go index d8d84b0da..dda42304b 100644 --- a/general_tests/data_it_test.go +++ b/general_tests/data_it_test.go @@ -180,7 +180,7 @@ func testV1DataDataDebitUsageWith10Kilo(t *testing.T) { &engine.UsageRecordWithOpts{UsageRecord: usageRecord}, &reply); err != nil { t.Error(err) } - if time.Now().Sub(tStart) > time.Duration(50*time.Millisecond) { + if time.Now().Sub(tStart) > 50*time.Millisecond { t.Error("Take's too long for GetDataCost") } @@ -207,7 +207,7 @@ func testV1DataGetCostWith10Kilo(t *testing.T) { } else if rply.Cost != 25600.000000 { t.Errorf("Unexpected cost received: %f", rply.Cost) } - if time.Now().Sub(tStart) > time.Duration(50*time.Millisecond) { + if time.Now().Sub(tStart) > 50*time.Millisecond { t.Error("Take's too long for GetDataCost") } } @@ -254,7 +254,7 @@ func testV1DataDebitBalanceWith10Kilo(t *testing.T) { } else if reply != utils.OK { t.Errorf("Received: %s", reply) } - if time.Now().Sub(tStart) > time.Duration(50*time.Millisecond) { + if time.Now().Sub(tStart) > 50*time.Millisecond { t.Error("Take's too long for GetDataCost") } @@ -318,7 +318,7 @@ func testV1DataDataDebitUsage1G0(t *testing.T) { &engine.UsageRecordWithOpts{UsageRecord: usageRecord}, &reply); err != nil { t.Error(err) } - if time.Now().Sub(tStart) > time.Duration(50*time.Millisecond) { + if time.Now().Sub(tStart) > 50*time.Millisecond { t.Errorf("Take's too long for GetDataCost : %+v", time.Now().Sub(tStart)) } @@ -345,7 +345,7 @@ func testV1DataGetCost1G0(t *testing.T) { } else if rply.Cost != 100000.000000 { t.Errorf("Unexpected cost received: %f", rply.Cost) } - if time.Now().Sub(tStart) > time.Duration(50*time.Millisecond) { + if time.Now().Sub(tStart) > 50*time.Millisecond { t.Error("Take's too long for GetDataCost") } } @@ -392,7 +392,7 @@ func testV1DataDebitBalance1G0(t *testing.T) { } else if reply != utils.OK { t.Errorf("Received: %s", reply) } - if time.Now().Sub(tStart) > time.Duration(50*time.Millisecond) { + if time.Now().Sub(tStart) > 50*time.Millisecond { t.Error("Take's too long for GetDataCost") } diff --git a/general_tests/doubleremove_it_test.go b/general_tests/doubleremove_it_test.go index c198dc0be..8f6890db1 100644 --- a/general_tests/doubleremove_it_test.go +++ b/general_tests/doubleremove_it_test.go @@ -119,7 +119,7 @@ func testdoubleRemoveStatQueueProfile(t *testing.T) { ExpiryTime: time.Date(2020, 4, 18, 14, 25, 0, 0, time.UTC), }, QueueLength: 10, - TTL: time.Duration(10) * time.Second, + TTL: 10 * time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: "*sum", diff --git a/general_tests/export_it_test.go b/general_tests/export_it_test.go index 6ef412f8c..1bf713841 100644 --- a/general_tests/export_it_test.go +++ b/general_tests/export_it_test.go @@ -244,7 +244,7 @@ func testExpVerifyThresholds(t *testing.T) { }, MaxHits: 1, MinHits: 1, - MinSleep: time.Duration(1 * time.Second), + MinSleep: time.Second, Blocker: false, Weight: 10.0, ActionIDs: []string{"ACT_LOG_WARNING"}, @@ -268,7 +268,7 @@ func testExpVerifyResources(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, - UsageTTL: time.Duration(-1), + UsageTTL: -1, Limit: 7, Blocker: false, Stored: true, @@ -293,7 +293,7 @@ func testExpVerifyStats(t *testing.T) { ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(-1), + TTL: -1, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaTCC, @@ -317,7 +317,7 @@ func testExpVerifyStats(t *testing.T) { ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(-1), + TTL: -1, Metrics: []*engine.MetricWithFilters{ { MetricID: utils.MetaTCD, diff --git a/general_tests/filters_it_test.go b/general_tests/filters_it_test.go index 88d4bee47..1cb42d89a 100644 --- a/general_tests/filters_it_test.go +++ b/general_tests/filters_it_test.go @@ -141,7 +141,7 @@ func testV1FltrAddStats(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 10.0, }, }, @@ -160,7 +160,7 @@ func testV1FltrAddStats(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1001", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 10.5, }, } @@ -177,7 +177,7 @@ func testV1FltrAddStats(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(5 * time.Second), + utils.Usage: 5 * time.Second, utils.COST: 12.5, }, } @@ -194,7 +194,7 @@ func testV1FltrAddStats(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1002", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(6 * time.Second), + utils.Usage: 6 * time.Second, utils.COST: 17.5, }, } @@ -211,7 +211,7 @@ func testV1FltrAddStats(t *testing.T) { Event: map[string]interface{}{ utils.Account: "1003", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 12.5, }, } @@ -228,9 +228,9 @@ func testV1FltrAddStats(t *testing.T) { Event: map[string]interface{}{ "Stat": "Stat1_1", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(11 * time.Second), + utils.Usage: 11 * time.Second, utils.COST: 12.5, - utils.PDD: time.Duration(12 * time.Second), + utils.PDD: 12 * time.Second, }, } if err := fltrRpc.Call(utils.StatSv1ProcessEvent, &ev1, &reply); err != nil { @@ -246,9 +246,9 @@ func testV1FltrAddStats(t *testing.T) { Event: map[string]interface{}{ "Stat": "Stat1_1", utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: time.Duration(15 * time.Second), + utils.Usage: 15 * time.Second, utils.COST: 15.5, - utils.PDD: time.Duration(15 * time.Second), + utils.PDD: 15 * time.Second, }, } if err := fltrRpc.Call(utils.StatSv1ProcessEvent, &ev1, &reply); err != nil { @@ -303,7 +303,7 @@ func testV1FltrPupulateThreshold(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(1 * time.Millisecond), + MinSleep: time.Millisecond, Weight: 10.0, ActionIDs: []string{"LOG"}, Async: true, @@ -379,7 +379,7 @@ func testV1FltrGetThresholdForEvent2(t *testing.T) { ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, MaxHits: -1, - MinSleep: time.Duration(1 * time.Millisecond), + MinSleep: time.Millisecond, Weight: 10.0, ActionIDs: []string{"LOG"}, }, @@ -412,7 +412,7 @@ func testV1FltrPopulateResources(t *testing.T) { rlsConfig := &engine.ResourceProfile{ Tenant: "cgrates.org", ID: "ResTest", - UsageTTL: time.Duration(1) * time.Minute, + UsageTTL: time.Minute, Limit: 10, AllocationMessage: "MessageAllocation", Stored: true, @@ -482,7 +482,7 @@ func testV1FltrPopulateResources(t *testing.T) { ID: "TH_ResTest", FilterIDs: []string{"FLTR_TH_Resource", "*string:~*req.Account:2020"}, MaxHits: -1, - MinSleep: time.Duration(1 * time.Millisecond), + MinSleep: time.Millisecond, Weight: 10.0, ActionIDs: []string{"LOG"}, Async: true, @@ -602,7 +602,7 @@ func testV1FltrAccounts(t *testing.T) { ID: "TH_Account", FilterIDs: []string{"FLTR_TH_Accounts", "*string:~*req.Account:1001"}, MaxHits: -1, - MinSleep: time.Duration(1 * time.Millisecond), + MinSleep: time.Millisecond, Weight: 90.0, ActionIDs: []string{"LOG"}, Async: true, @@ -692,7 +692,7 @@ func testV1FltrAccountsExistsDynamicaly(t *testing.T) { ID: "TH_AccountDinamic", FilterIDs: []string{"*exists:~*accounts.<~*req.Account>:"}, MaxHits: -1, - MinSleep: time.Duration(1 * time.Millisecond), + MinSleep: time.Millisecond, Weight: 90.0, ActionIDs: []string{"LOG"}, Async: true, diff --git a/general_tests/gocs_it_test.go b/general_tests/gocs_it_test.go index becf47427..cad1adf2c 100644 --- a/general_tests/gocs_it_test.go +++ b/general_tests/gocs_it_test.go @@ -186,7 +186,7 @@ func testGOCSLoadData(t *testing.T) { }() select { case <-wchan: - case <-time.After(1 * time.Second): + case <-time.After(time.Second): t.Errorf("cgr-loader failed: ") } var acnt *engine.Account @@ -293,8 +293,8 @@ func testGOCSInitSession(t *testing.T) { t.Errorf("wrong active sessions: %s \n , and len(aSessions) %+v", utils.ToJSON(aSessions), len(aSessions)) } else if aSessions[0].NodeID != "AU_SITE" { t.Errorf("Expecting : %+v, received: %+v", "AU_SITE", aSessions[0].NodeID) - } else if aSessions[0].Usage != time.Duration(5*time.Minute) { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(5*time.Minute), aSessions[0].MaxCostSoFar) + } else if aSessions[0].Usage != 5*time.Minute { + t.Errorf("Expecting : %+v, received: %+v", 5*time.Minute, aSessions[0].MaxCostSoFar) } aSessions = make([]*sessions.ExternalSession, 0) @@ -304,8 +304,8 @@ func testGOCSInitSession(t *testing.T) { t.Errorf("wrong active sessions: %s \n , and len(aSessions) %+v", utils.ToJSON(aSessions), len(aSessions)) } else if aSessions[0].NodeID != "US_SITE" { t.Errorf("Expecting : %+v, received: %+v", "US_SITE", aSessions[0].NodeID) - } else if aSessions[0].Usage != time.Duration(5*time.Minute) { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(5*time.Minute), aSessions[0].Usage) + } else if aSessions[0].Usage != 5*time.Minute { + t.Errorf("Expecting : %+v, received: %+v", 5*time.Minute, aSessions[0].Usage) } var acnt *engine.Account @@ -368,8 +368,8 @@ func testGOCSUpdateSession(t *testing.T) { t.Errorf("wrong active sessions: %s", utils.ToJSON(aSessions)) } else if aSessions[0].NodeID != "AU_SITE" { t.Errorf("Expecting : %+v, received: %+v", "AU_SITE", aSessions[0].NodeID) - } else if aSessions[0].Usage != time.Duration(10*time.Minute) { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(5*time.Minute), aSessions[0].Usage) + } else if aSessions[0].Usage != 10*time.Minute { + t.Errorf("Expecting : %+v, received: %+v", 5*time.Minute, aSessions[0].Usage) } var acnt *engine.Account @@ -448,8 +448,8 @@ func testGOCSUpdateSession2(t *testing.T) { t.Errorf("wrong active sessions: %s", utils.ToJSON(aSessions)) } else if aSessions[0].NodeID != "AU_SITE" { t.Errorf("Expecting : %+v, received: %+v", "AU_SITE", aSessions[0].NodeID) - } else if aSessions[0].Usage != time.Duration(15*time.Minute) { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(15*time.Minute), aSessions[0].Usage) + } else if aSessions[0].Usage != 15*time.Minute { + t.Errorf("Expecting : %+v, received: %+v", 15*time.Minute, aSessions[0].Usage) } aSessions = make([]*sessions.ExternalSession, 0) @@ -459,8 +459,8 @@ func testGOCSUpdateSession2(t *testing.T) { t.Errorf("wrong active sessions: %s \n , and len(aSessions) %+v", utils.ToJSON(aSessions), len(aSessions)) } else if aSessions[0].NodeID != "US_SITE" { t.Errorf("Expecting : %+v, received: %+v", "US_SITE", aSessions[0].NodeID) - } else if aSessions[0].Usage != time.Duration(10*time.Minute) { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(5*time.Minute), aSessions[0].Usage) + } else if aSessions[0].Usage != 10*time.Minute { + t.Errorf("Expecting : %+v, received: %+v", 5*time.Minute, aSessions[0].Usage) } var acnt *engine.Account diff --git a/general_tests/oldtutorial_it_test.go b/general_tests/oldtutorial_it_test.go index e3ee5c130..94ae7ee51 100644 --- a/general_tests/oldtutorial_it_test.go +++ b/general_tests/oldtutorial_it_test.go @@ -312,7 +312,7 @@ package general_tests // Account: "1001", // Destination: "1007", // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(50) * time.Second), +// TimeEnd: tStart.Add(50 * time.Second), // } // if err := tutLocalRpc.Call(utils.ResponderGetCost, cd, &cc); err != nil { // t.Error("Got error on Responder.GetCost: ", err.Error()) @@ -326,7 +326,7 @@ package general_tests // Account: "1001", // Destination: "1007", // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(70) * time.Second), +// TimeEnd: tStart.Add(70 * time.Second), // } // if err := tutLocalRpc.Call(utils.ResponderGetCost, cd, &cc); err != nil { // t.Error("Got error on Responder.GetCost: ", err.Error()) @@ -340,7 +340,7 @@ package general_tests // Account: "1002", // Destination: "1007", // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(50) * time.Second), +// TimeEnd: tStart.Add(50 * time.Second), // } // if err := tutLocalRpc.Call(utils.ResponderGetCost, cd, &cc); err != nil { // t.Error("Got error on Responder.GetCost: ", err.Error()) @@ -354,7 +354,7 @@ package general_tests // Account: "1002", // Destination: "1007", // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(70) * time.Second), +// TimeEnd: tStart.Add(70 * time.Second), // } // if err := tutLocalRpc.Call(utils.ResponderGetCost, cd, &cc); err != nil { // t.Error("Got error on Responder.GetCost: ", err.Error()) @@ -416,7 +416,7 @@ package general_tests // Destination: "1002", // DurationIndex: 0, // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(20) * time.Second), +// TimeEnd: tStart.Add(20 * time.Second), // } // var cc engine.CallCost // if err := tutLocalRpc.Call(utils.ResponderMaxDebit, cd, &cc); err != nil { @@ -432,7 +432,7 @@ package general_tests // Destination: "1003", // DurationIndex: 0, // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(200) * time.Second), +// TimeEnd: tStart.Add(200 * time.Second), // } // if err := tutLocalRpc.Call(utils.ResponderMaxDebit, cd, &cc); err != nil { // t.Error("Got error on Responder.MaxDebit: ", err.Error()) @@ -447,7 +447,7 @@ package general_tests // Destination: "1007", // DurationIndex: 0, // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(120) * time.Second), +// TimeEnd: tStart.Add(120 * time.Second), // } // cd.CgrID = "1" // if err := tutLocalRpc.Call(utils.ResponderMaxDebit, cd, &cc); err != nil { @@ -463,12 +463,12 @@ package general_tests // Destination: "1007", // DurationIndex: 0, // TimeStart: tStart, -// TimeEnd: tStart.Add(time.Duration(120) * time.Second), +// TimeEnd: tStart.Add(120 * time.Second), // } // cd.CgrID = "2" // if err := tutLocalRpc.Call(utils.ResponderMaxDebit, cd, &cc); err != nil { // t.Error("Got error on Responder.GetCost: ", err.Error()) -// } else if cc.GetDuration() != time.Duration(62)*time.Second { // We have as strategy *dsconnect +// } else if cc.GetDuration() != 62*time.Second { // We have as strategy *dsconnect // t.Errorf("Calling Responder.MaxDebit got callcost: %v", cc.GetDuration()) // } // var maxTime float64 @@ -495,7 +495,7 @@ package general_tests // Destination: "1007", // SetupTime: tStart, // AnswerTime: tStart, -// Usage: time.Duration(120) * time.Second, +// Usage: 120 * time.Second, // Cost: -1, // } // var maxTime float64 @@ -953,7 +953,7 @@ package general_tests // Subject: "1001", Destination: "1002", // SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), // AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), -// Usage: time.Duration(2) * time.Minute, +// Usage: 2 * time.Minute, // ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} // testCdr2 := &engine.CDR{CGRID: utils.Sha1("testcdr2", // time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), @@ -963,7 +963,7 @@ package general_tests // Subject: "1002", Destination: "1003", // SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), // AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), -// Usage: time.Duration(90) * time.Second, +// Usage: 90 * time.Second, // ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} // var reply string // for _, cdr := range []*engine.CDR{testCdr1, testCdr2} { @@ -1004,7 +1004,7 @@ package general_tests // ToR: utils.VOICE, OriginID: "testcdr3", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, // Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1004", // SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), -// Usage: time.Duration(180) * time.Second} +// Usage: 180 * time.Second} // if err := tutLocalRpc.Call(utils.CDRsV1ProcessCDR, testCdr3, &reply); err != nil { // t.Error("Unexpected error: ", err.Error()) // } else if reply != utils.OK { @@ -1066,7 +1066,7 @@ package general_tests // ToR: utils.VOICE, OriginID: "testcdr4", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, // Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1004", // SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), -// Usage: time.Duration(60) * time.Second} +// Usage: 60 * time.Second} // var reply string // if err := tutLocalRpc.Call(utils.CDRsV1ProcessCDR, testCdr4, &reply); err != nil { // Should drop ACD under the 2m required by threshold, removing suppl2 from lcr // t.Error("Unexpected error: ", err.Error()) @@ -1130,7 +1130,7 @@ package general_tests // ToR: utils.VOICE, OriginID: "testcdr5", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, // Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1004", // SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), -// Usage: time.Duration(1) * time.Second} +// Usage: time.Second} // if err := tutLocalRpc.Call(utils.CDRsV1ProcessCDR, testCdr5, &reply); err != nil { // Should drop ACD under the 1m required by threshold, removing suppl2 from lcr // t.Error("Unexpected error: ", err.Error()) // } else if reply != utils.OK { @@ -1310,7 +1310,7 @@ package general_tests // Category: "call", Account: "1001", Subject: "1001", Destination: "1003", // SetupTime: time.Date(2016, 4, 6, 13, 29, 24, 0, time.UTC), // AnswerTime: time.Date(2016, 4, 6, 13, 30, 0, 0, time.UTC), -// Usage: time.Duration(90) * time.Second, +// Usage: 90 * time.Second, // ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} // cc := &engine.CallCost{ @@ -1377,7 +1377,7 @@ package general_tests // ToR: utils.VOICE, OriginID: "testprepaid2", OriginHost: "192.168.1.1", Source: "TEST_PREPAID_CDR_NO_SMCOST1", RequestType: utils.META_PREPAID, // Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1003", // SetupTime: time.Date(2016, 4, 6, 13, 29, 24, 0, time.UTC), AnswerTime: time.Date(2016, 4, 6, 13, 30, 0, 0, time.UTC), -// Usage: time.Duration(90) * time.Second, +// Usage: 90 * time.Second, // ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} // var reply string // if err := tutLocalRpc.Call(utils.CDRsV1ProcessCDR, cdr, &reply); err != nil { @@ -1386,7 +1386,7 @@ package general_tests // t.Error("Unexpected reply received: ", reply) // } // /* -// time.Sleep(time.Duration(7000) * time.Millisecond) // Give time for CDR to be processed +// time.Sleep(7000 * time.Millisecond) // Give time for CDR to be processed // var cdrs []*engine.ExternalCDR // req := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, CGRIDs: []string{cdr.CGRID}} // if err := tutLocalRpc.Call(utils.APIerSv2GetCDRs, req, &cdrs); err != nil { @@ -1408,7 +1408,7 @@ package general_tests // cdr := &engine.CDR{ToR: utils.VOICE, OriginID: "testexportcdr1", OriginHost: "192.168.1.1", Source: "TestTutITExportCDR", RequestType: utils.META_RATED, // Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1003", // SetupTime: time.Date(2016, 11, 30, 17, 5, 24, 0, time.UTC), AnswerTime: time.Date(2016, 11, 30, 17, 6, 4, 0, time.UTC), -// Usage: time.Duration(98) * time.Second, +// Usage: 98 * time.Second, // ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} // cdr.ComputeCGRID() // var reply string @@ -1417,7 +1417,7 @@ package general_tests // } else if reply != utils.OK { // t.Error("Unexpected reply received: ", reply) // } -// time.Sleep(time.Duration(50) * time.Millisecond) // Give time for CDR to be processed +// time.Sleep(50 * time.Millisecond) // Give time for CDR to be processed // var cdrs []*engine.ExternalCDR // req := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, CGRIDs: []string{cdr.CGRID}} // if err := tutLocalRpc.Call(utils.APIerSv2GetCDRs, req, &cdrs); err != nil { diff --git a/general_tests/resourcesv1_it_test.go b/general_tests/resourcesv1_it_test.go index 8315c8a11..ab7e48432 100644 --- a/general_tests/resourcesv1_it_test.go +++ b/general_tests/resourcesv1_it_test.go @@ -114,7 +114,7 @@ func testV1RsSetProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(-1), + UsageTTL: -1, Limit: 2, AllocationMessage: "Account1Channels", Weight: 20, diff --git a/general_tests/route_it_test.go b/general_tests/route_it_test.go index e016d755c..c5ff2a08d 100644 --- a/general_tests/route_it_test.go +++ b/general_tests/route_it_test.go @@ -256,7 +256,7 @@ func testV1SplSAddNewResPrf(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1) * time.Minute, + UsageTTL: time.Minute, Limit: 10, Stored: true, Weight: 20, @@ -279,7 +279,7 @@ func testV1SplSAddNewResPrf(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1) * time.Minute, + UsageTTL: time.Minute, Limit: 10, Stored: true, Weight: 30, @@ -302,7 +302,7 @@ func testV1SplSAddNewResPrf(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1) * time.Minute, + UsageTTL: time.Minute, Limit: 10, Stored: true, Weight: 20, @@ -325,7 +325,7 @@ func testV1SplSAddNewResPrf(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1) * time.Minute, + UsageTTL: time.Minute, Limit: 10, Stored: true, Weight: 20, diff --git a/general_tests/rpccaching_it_test.go b/general_tests/rpccaching_it_test.go index 744986d60..6d1ee5d87 100644 --- a/general_tests/rpccaching_it_test.go +++ b/general_tests/rpccaching_it_test.go @@ -170,7 +170,7 @@ func testRPCMethodsAddData(t *testing.T) { ID: "THD_AccDisableAndLog", FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*req.DisableAction:DisableAction"}, MaxHits: -1, - MinSleep: time.Duration(1 * time.Second), + MinSleep: time.Second, Weight: 30.0, ActionIDs: []string{"DISABLE_LOG"}, }, @@ -187,7 +187,7 @@ func testRPCMethodsAddData(t *testing.T) { ID: "THD_AccEnableAndLog", FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*req.EnableAction:EnableAction"}, MaxHits: -1, - MinSleep: time.Duration(1 * time.Second), + MinSleep: time.Second, Weight: 30.0, ActionIDs: []string{"ENABLE_LOG"}, }, @@ -273,7 +273,7 @@ func testRPCMethodsAuthorizeSession(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) //authorize again session (this time we expect to receive an error) if err := rpcRpc.Call(utils.SessionSv1AuthorizeEvent, args, &rply); err == nil || err.Error() != "RALS_ERROR:ACCOUNT_DISABLED" { @@ -372,7 +372,7 @@ func testRPCMethodsInitSession(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) if err := rpcRpc.Call(utils.SessionSv1InitiateSession, args, &rply); err == nil || !(err.Error() == "RALS_ERROR:ACCOUNT_DISABLED" || @@ -472,7 +472,7 @@ func testRPCMethodsUpdateSession(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) if err := rpcRpc.Call(utils.SessionSv1UpdateSession, args, &rply); err == nil || err.Error() != "RALS_ERROR:ACCOUNT_DISABLED" { @@ -537,7 +537,7 @@ func testRPCMethodsTerminateSession(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) if err := rpcRpc.Call(utils.SessionSv1TerminateSession, args, &rply); err == nil || err.Error() != "MANDATORY_IE_MISSING: [OriginID]" { @@ -601,7 +601,7 @@ func testRPCMethodsProcessCDR(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) //change originID so CGRID be different args.Event[utils.OriginID] = "testRPCMethodsProcessCDR3" @@ -695,7 +695,7 @@ func testRPCMethodsProcessEvent(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) if err := rpcRpc.Call(utils.SessionSv1ProcessMessage, args, &rplyFirst); err == nil || err.Error() != "RALS_ERROR:ACCOUNT_DISABLED" { @@ -744,7 +744,7 @@ func testRPCMethodsCdrsProcessCDR(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated //verify the CDR var cdrs []*engine.CDR argsCDR := utils.RPCCDRsFilterWithOpts{RPCCDRsFilter: &utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}}} @@ -770,7 +770,7 @@ func testRPCMethodsCdrsProcessCDR(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) //change originID so CGRID be different args.Event[utils.OriginID] = "testRPCMethodsProcessCDR4" if err := rpcRpc.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil { @@ -778,7 +778,7 @@ func testRPCMethodsCdrsProcessCDR(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) // Give time for CDR to be rated + time.Sleep(150 * time.Millisecond) // Give time for CDR to be rated //verify the CDR if err := rpcRpc.Call(utils.CDRsV1GetCDRs, &argsCDR, &cdrs); err != nil { t.Error("Unexpected error: ", err.Error()) @@ -816,7 +816,7 @@ func testRPCMethodsCdrsStoreSessionCost(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(150) * time.Millisecond) + time.Sleep(150 * time.Millisecond) //change originID so CGRID be different args.Cost.CGRID = "testRPCMethodsCdrsStoreSessionCost" @@ -828,7 +828,7 @@ func testRPCMethodsCdrsStoreSessionCost(t *testing.T) { } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) //change originID so CGRID be different args.Cost.CGRID = "testRPCMethodsCdrsStoreSessionCost" if err := rpcRpc.Call(utils.CDRsV2StoreSessionCost, args, @@ -857,7 +857,7 @@ func testRPCMethodsResponderDebit(t *testing.T) { Destination: "+49", DurationIndex: 0, TimeStart: tStart, - TimeEnd: tStart.Add(time.Duration(15) * time.Second), + TimeEnd: tStart.Add(15 * time.Second), }, } var cc engine.CallCost @@ -885,7 +885,7 @@ func testRPCMethodsResponderDebit(t *testing.T) { utils.ToJSON(cc), utils.ToJSON(ccCache)) } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) if err := rpcRpc.Call(utils.ResponderDebit, cd2, &cc); err == nil || err.Error() != "ACCOUNT_NOT_FOUND" { t.Error("Unexpected error returned", err) } @@ -903,7 +903,7 @@ func testRPCMethodsResponderMaxDebit(t *testing.T) { Destination: "+49", DurationIndex: 0, TimeStart: tStart, - TimeEnd: tStart.Add(time.Duration(15) * time.Second), + TimeEnd: tStart.Add(15 * time.Second), }, } var cc engine.CallCost @@ -931,7 +931,7 @@ func testRPCMethodsResponderMaxDebit(t *testing.T) { utils.ToJSON(cc), utils.ToJSON(ccCache)) } //give time to CGRateS to delete the response from cache - time.Sleep(1*time.Second + 500*time.Millisecond) + time.Sleep(time.Second + 500*time.Millisecond) if err := rpcRpc.Call(utils.ResponderMaxDebit, cd2, &cc); err == nil || err.Error() != "ACCOUNT_NOT_FOUND" { t.Error("Unexpected error returned", err) } diff --git a/general_tests/rpcclient_it_test.go b/general_tests/rpcclient_it_test.go index 1e3f7926a..08630cc17 100644 --- a/general_tests/rpcclient_it_test.go +++ b/general_tests/rpcclient_it_test.go @@ -119,13 +119,13 @@ func testRPCITLclStartSecondEngine(t *testing.T) { func testRPCITLclRpcConnPoolFirst(t *testing.T) { rpcPoolFirst = rpcclient.NewRPCPool(rpcclient.PoolFirst, 0) rpcRAL1, err = rpcclient.NewRPCClient(utils.TCP, rpcITCfg1.ListenCfg().RPCJSONListen, false, "", "", "", 3, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) + time.Second, 2*time.Second, rpcclient.JSONrpc, nil, false) if err == nil { t.Fatal("Should receive cannot connect error here") } rpcPoolFirst.AddClient(rpcRAL1) rpcRAL2, err = rpcclient.NewRPCClient(utils.TCP, rpcITCfg2.ListenCfg().RPCJSONListen, false, "", "", "", 3, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) + time.Second, 2*time.Second, rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal(err) } @@ -228,7 +228,7 @@ func testRPCITLclTDirectedRPC(t *testing.T) { // Connect rpc client to rater func testRPCITLclRpcConnPoolBcast(t *testing.T) { - rpcPoolBroadcast = rpcclient.NewRPCPool(rpcclient.PoolBroadcast, time.Duration(2*time.Second)) + rpcPoolBroadcast = rpcclient.NewRPCPool(rpcclient.PoolBroadcast, 2*time.Second) rpcPoolBroadcast.AddClient(rpcRAL1) rpcPoolBroadcast.AddClient(rpcRAL2) } @@ -353,13 +353,13 @@ func TestRPCITRmtRpcConnPool(t *testing.T) { } rpcPoolFirst = rpcclient.NewRPCPool(rpcclient.PoolFirst, 0) rpcRALRmt, err := rpcclient.NewRPCClient(utils.TCP, RemoteRALsAddr1, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) + time.Second, 2*time.Second, rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal(err) } rpcPoolFirst.AddClient(rpcRALRmt) rpcRAL1, err = rpcclient.NewRPCClient(utils.TCP, RemoteRALsAddr2, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) + time.Second, 2*time.Second, rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal(err) } @@ -391,7 +391,7 @@ func TestRPCITRmtStatusFirstFailover(t *testing.T) { remaining := 5 for i := 0; i < remaining; i++ { fmt.Printf("\n\t%d", remaining-i) - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } fmt.Println("\n\nExecuting query ...") var status map[string]interface{} @@ -419,7 +419,7 @@ func TestRPCITRmtStatusFirstFailback(t *testing.T) { remaining := 10 for i := 0; i < remaining; i++ { fmt.Printf("\n\t%d", remaining-i) - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } fmt.Println("\n\nExecuting query ...") var status map[string]interface{} diff --git a/general_tests/session_it_test.go b/general_tests/session_it_test.go index 19841c0c4..a151759f2 100644 --- a/general_tests/session_it_test.go +++ b/general_tests/session_it_test.go @@ -200,7 +200,7 @@ func testSesItTerminateSession(t *testing.T) { utils.Destination: "TEST", utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 1 * time.Second, + utils.Usage: time.Second, }, }, }, diff --git a/general_tests/sessionrefund_it_test.go b/general_tests/sessionrefund_it_test.go index e7c71fb09..26e0590dd 100644 --- a/general_tests/sessionrefund_it_test.go +++ b/general_tests/sessionrefund_it_test.go @@ -202,7 +202,7 @@ func testSrItTerminateSession(t *testing.T) { utils.Destination: "TEST", utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 0 * time.Second, + utils.Usage: 0, }, }, }, @@ -295,7 +295,7 @@ func testSrItTerminateSession2(t *testing.T) { utils.Destination: "1001", utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 0 * time.Second, + utils.Usage: 0, }, }, }, diff --git a/general_tests/sessions_concur_test.go b/general_tests/sessions_concur_test.go index 15b9018d7..62fba678b 100644 --- a/general_tests/sessions_concur_test.go +++ b/general_tests/sessions_concur_test.go @@ -149,7 +149,7 @@ func testSCncrLoadTP(t *testing.T) { func testSCncrRunSessions(t *testing.T) { acntIDsSet := utils.NewStringSet(nil) - bufferTopup := time.Duration(8760) * time.Hour + bufferTopup := 8760 * time.Hour for i := 0; i < *sCncrSessions; i++ { acntID := fmt.Sprintf("100%d", utils.RandomInteger(100, 200)) if !acntIDsSet.Has(acntID) { @@ -197,13 +197,13 @@ func testRunSession(t *testing.T) { defer wg.Done() // decrease group counter one out from test cpsPool <- struct{}{} // push here up to cps go func() { // allow more requests after a second - time.Sleep(time.Duration(time.Second)) + time.Sleep(time.Second) <-cpsPool }() acntID := <-acntIDs originID := utils.GenUUID() // each test with it's own OriginID // topup as much as we know we need for one session - mainTopup := time.Duration(90) * time.Second + mainTopup := 90 * time.Second var addBlcRply string argsAddBalance := &v1.AttrAddBalance{ Tenant: "cgrates.org", @@ -249,7 +249,7 @@ func testRunSession(t *testing.T) { utils.RandomInteger(0, 100)) * time.Millisecond) // Init the session - initUsage := 1 * time.Minute + initUsage := time.Minute initArgs := &sessions.V1InitSessionArgs{ InitSession: true, GetAttributes: true, @@ -279,7 +279,7 @@ func testRunSession(t *testing.T) { // Update the session with relocate initOriginID := originID originID = utils.GenUUID() - updtUsage := 1 * time.Minute + updtUsage := time.Minute updtArgs := &sessions.V1UpdateSessionArgs{ GetAttributes: true, UpdateSession: true, @@ -311,7 +311,7 @@ func testRunSession(t *testing.T) { ID: fmt.Sprintf("TestSCncrTerminate%s", originID), Event: map[string]interface{}{ utils.OriginID: originID, - utils.Usage: time.Duration(90 * time.Second), + utils.Usage: 90 * time.Second, }, }, } @@ -342,7 +342,7 @@ func testRunSession(t *testing.T) { } else if rplyCDR != utils.OK { t.Errorf("received: <%s> to ProcessCDR", rplyCDR) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(20 * time.Millisecond) var cdrs []*engine.ExternalCDR argCDRs := utils.RPCCDRsFilter{OriginIDs: []string{originID}} if err := sCncrRPC.Call(utils.APIerSv2GetCDRs, &argCDRs, &cdrs); err != nil { diff --git a/general_tests/smschrg1_test.go b/general_tests/smschrg1_test.go index b29e5edf0..af2bbe8c3 100644 --- a/general_tests/smschrg1_test.go +++ b/general_tests/smschrg1_test.go @@ -79,7 +79,7 @@ func TestSMSLoadCsvTpSmsChrg1(t *testing.T) { } func TestSMSGetDataCostSmsChrg1(t *testing.T) { - usageDur := time.Duration(1) + usageDur := time.Nanosecond timeStart := time.Date(2014, 3, 4, 0, 0, 0, 0, time.Local) cd := &engine.CallDescriptor{ Category: "sms", diff --git a/general_tests/suretax_it_test.go b/general_tests/suretax_it_test.go index 9d3bfb0d6..1f21bb188 100644 --- a/general_tests/suretax_it_test.go +++ b/general_tests/suretax_it_test.go @@ -141,7 +141,7 @@ func testSTIProcessExternalCdr(t *testing.T) { } else if reply != utils.OK { t.Error("Unexpected reply received: ", reply) } - time.Sleep(time.Duration(2) * time.Second) + time.Sleep(2 * time.Second) } func testSTIGetCdrs(t *testing.T) { diff --git a/general_tests/tls_it_test.go b/general_tests/tls_it_test.go index b2b4cea17..1639a28b7 100755 --- a/general_tests/tls_it_test.go +++ b/general_tests/tls_it_test.go @@ -86,21 +86,21 @@ func testTLSRpcConn(t *testing.T) { var err error tlsRpcClientJson, err = rpcclient.NewRPCClient(utils.TCP, "localhost:2022", true, tlsCfg.TlsCfg().ClientKey, tlsCfg.TlsCfg().ClientCerificate, tlsCfg.TlsCfg().CaCertificate, 3, 3, - time.Duration(1*time.Second), time.Duration(5*time.Minute), rpcclient.JSONrpc, nil, false) + time.Second, 5*time.Minute, rpcclient.JSONrpc, nil, false) if err != nil { t.Errorf("Error: %s when dialing", err) } tlsRpcClientGob, err = rpcclient.NewRPCClient(utils.TCP, "localhost:2023", true, tlsCfg.TlsCfg().ClientKey, tlsCfg.TlsCfg().ClientCerificate, tlsCfg.TlsCfg().CaCertificate, 3, 3, - time.Duration(1*time.Second), time.Duration(5*time.Minute), rpcclient.GOBrpc, nil, false) + time.Second, 5*time.Minute, rpcclient.GOBrpc, nil, false) if err != nil { t.Errorf("Error: %s when dialing", err) } tlsHTTPJson, err = rpcclient.NewRPCClient(utils.TCP, "https://localhost:2280/jsonrpc", true, tlsCfg.TlsCfg().ClientKey, tlsCfg.TlsCfg().ClientCerificate, tlsCfg.TlsCfg().CaCertificate, 3, 3, - time.Duration(1*time.Second), time.Duration(5*time.Minute), rpcclient.HTTPjson, nil, false) + time.Second, 5*time.Minute, rpcclient.HTTPjson, nil, false) if err != nil { t.Errorf("Error: %s when dialing", err) } @@ -134,7 +134,7 @@ func testTLSPing(t *testing.T) { t.Error(err) } - initUsage := time.Duration(5 * time.Minute) + initUsage := 5 * time.Minute args := &sessions.V1InitSessionArgs{ InitSession: true, AllocateResources: true, diff --git a/general_tests/tp_it_test.go b/general_tests/tp_it_test.go index 9ecd2103f..15e61db55 100644 --- a/general_tests/tp_it_test.go +++ b/general_tests/tp_it_test.go @@ -138,7 +138,7 @@ func testTpBalanceCounter(t *testing.T) { Destination: "+49", DurationIndex: 0, TimeStart: tStart, - TimeEnd: tStart.Add(time.Duration(20) * time.Second), + TimeEnd: tStart.Add(20 * time.Second), }, } var cc engine.CallCost @@ -223,7 +223,7 @@ func testTpZeroCost(t *testing.T) { Destination: "+49", DurationIndex: 0, TimeStart: tStart, - TimeEnd: tStart.Add(time.Duration(20) * time.Second), + TimeEnd: tStart.Add(20 * time.Second), }, } var cc engine.CallCost @@ -250,7 +250,7 @@ func testTpZeroNegativeCost(t *testing.T) { Destination: "+4915", DurationIndex: 0, TimeStart: tStart, - TimeEnd: tStart.Add(time.Duration(20) * time.Second), + TimeEnd: tStart.Add(20 * time.Second), }, } var cc engine.CallCost diff --git a/general_tests/tut_smgeneric_it_test.go b/general_tests/tut_smgeneric_it_test.go index cada5dd76..e02414f50 100644 --- a/general_tests/tut_smgeneric_it_test.go +++ b/general_tests/tut_smgeneric_it_test.go @@ -140,7 +140,6 @@ func testTutSMGCacheStats(t *testing.T) { expectedStats[utils.CacheRatingProfiles].Items = 5 expectedStats[utils.CacheActions].Items = 9 expectedStats[utils.CacheActionPlans].Items = 4 - expectedStats[utils.CacheAccountActionPlans].Items = 5 expectedStats[utils.CacheSharedGroups].Items = 1 expectedStats[utils.CacheResourceProfiles].Items = 3 expectedStats[utils.CacheResources].Items = 3 diff --git a/general_tests/tutorial_calls_test.go b/general_tests/tutorial_calls_test.go index 834655ce9..bc87dffe5 100755 --- a/general_tests/tutorial_calls_test.go +++ b/general_tests/tutorial_calls_test.go @@ -376,7 +376,7 @@ func testCallStartPjsuaListener(t *testing.T) { func testCallCall1001To1002(t *testing.T) { if err := engine.PjsuaCallUri( &engine.PjsuaAccount{Id: "sip:1001@127.0.0.1", Username: "1001", Password: "CGRateS.org", Realm: "*"}, - "sip:1002@127.0.0.1", "sip:127.0.0.1:5080", time.Duration(67)*time.Second, 5071); err != nil { + "sip:1002@127.0.0.1", "sip:127.0.0.1:5080", 67*time.Second, 5071); err != nil { t.Fatal(err) } // give time to session to start so we can check it @@ -420,7 +420,7 @@ func testCallGetActiveSessions(t *testing.T) { func testCallCall1002To1001(t *testing.T) { if err := engine.PjsuaCallUri( &engine.PjsuaAccount{Id: "sip:1002@127.0.0.1", Username: "1002", Password: "CGRateS.org", Realm: "*"}, - "sip:1001@127.0.0.1", "sip:127.0.0.1:5080", time.Duration(65)*time.Second, 5072); err != nil { + "sip:1001@127.0.0.1", "sip:127.0.0.1:5080", 65*time.Second, 5072); err != nil { t.Fatal(err) } } @@ -483,7 +483,7 @@ func testCallCheckResourceAllocation(t *testing.T) { } } // Allow calls to finish before start querying the results - time.Sleep(time.Duration(50) * time.Second) + time.Sleep(50 * time.Second) } // Make sure account was debited properly @@ -710,16 +710,16 @@ func testCallSyncSessions(t *testing.T) { // 1001 call 1002 stop the call after 12 seconds if err := engine.PjsuaCallUri( &engine.PjsuaAccount{Id: "sip:1001@127.0.0.1", Username: "1001", Password: "CGRateS.org", Realm: "*"}, - "sip:1002@127.0.0.1", "sip:127.0.0.1:5080", time.Duration(120)*time.Second, 5076); err != nil { + "sip:1002@127.0.0.1", "sip:127.0.0.1:5080", 120*time.Second, 5076); err != nil { t.Fatal(err) } // 1001 call 1003 stop the call after 11 seconds if err := engine.PjsuaCallUri( &engine.PjsuaAccount{Id: "sip:1001@127.0.0.1", Username: "1001", Password: "CGRateS.org", Realm: "*"}, - "sip:1003@127.0.0.1", "sip:127.0.0.1:5080", time.Duration(120)*time.Second, 5077); err != nil { + "sip:1003@127.0.0.1", "sip:127.0.0.1:5080", 120*time.Second, 5077); err != nil { t.Fatal(err) } - time.Sleep(1 * time.Second) + time.Sleep(time.Second) // get active sessions if err := tutorialCallsRpc.Call(utils.SessionSv1GetActiveSessions, nil, &reply); err != nil { @@ -807,16 +807,16 @@ func testCallSyncSessions(t *testing.T) { t.Fatal("Unexpected number of CDRs returned: ", len(rplCdrs), utils.ToJSON(rplCdrs)) } else if time1, err := utils.ParseDurationWithSecs(rplCdrs[0].Usage); err != nil { t.Error(err) - } else if time1 > time.Duration(15*time.Second) { + } else if time1 > 15*time.Second { t.Error("Unexpected time duration : ", time1) } else if time1, err := utils.ParseDurationWithSecs(rplCdrs[1].Usage); err != nil { t.Error(err) - } else if time1 > time.Duration(15*time.Second) { + } else if time1 > 15*time.Second { t.Error("Unexpected time duration : ", time1) } else if numberOfCDR == 3 { if time1, err := utils.ParseDurationWithSecs(rplCdrs[2].Usage); err != nil { t.Error(err) - } else if time1 > time.Duration(15*time.Second) { + } else if time1 > 15*time.Second { t.Error("Unexpected time duration : ", time1) } } diff --git a/general_tests/twoengines_it_test.go b/general_tests/twoengines_it_test.go index f4f66fb1c..35967b0cf 100644 --- a/general_tests/twoengines_it_test.go +++ b/general_tests/twoengines_it_test.go @@ -151,7 +151,7 @@ func testTwoEnginesSetThreshold(t *testing.T) { ID: "THD_TwoEnginesTest", FilterIDs: []string{"*string:~*req.Account:1001"}, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1"}, @@ -212,7 +212,7 @@ func testTwoEnginesCheckCacheAfterSet(t *testing.T) { ID: "THD_TwoEnginesTest", FilterIDs: []string{"*string:~*req.Account:1001"}, MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{"ACT_1"}, @@ -237,7 +237,7 @@ func testTwoEnginesUpdateThreshold(t *testing.T) { ID: "THD_TwoEnginesTest", FilterIDs: []string{"*string:~*req.Account:10"}, MaxHits: -1, - MinSleep: time.Duration(1 * time.Minute), + MinSleep: time.Minute, Blocker: false, Weight: 50.0, ActionIDs: []string{"ACT_1.1"}, diff --git a/guardian/guardian_test.go b/guardian/guardian_test.go index f6d420f2d..2a57d13c9 100644 --- a/guardian/guardian_test.go +++ b/guardian/guardian_test.go @@ -50,7 +50,7 @@ func TestGuardianMultipleKeys(t *testing.T) { sg.Wait() mustExecDur := time.Duration(maxIter*100) * time.Millisecond if execTime := time.Now().Sub(tStart); execTime < mustExecDur || - execTime > mustExecDur+time.Duration(100*time.Millisecond) { + execTime > mustExecDur+100*time.Millisecond { t.Errorf("Execution took: %v", execTime) } Guardian.lkMux.Lock() @@ -71,7 +71,7 @@ func TestGuardianTimeout(t *testing.T) { for _, key := range keys { sg.Add(1) go func(key string) { - Guardian.Guard(delayHandler, time.Duration(10*time.Millisecond), key) + Guardian.Guard(delayHandler, 10*time.Millisecond, key) sg.Done() }(key) } @@ -79,7 +79,7 @@ func TestGuardianTimeout(t *testing.T) { sg.Wait() mustExecDur := time.Duration(maxIter*10) * time.Millisecond if execTime := time.Now().Sub(tStart); execTime < mustExecDur || - execTime > mustExecDur+time.Duration(100*time.Millisecond) { + execTime > mustExecDur+100*time.Millisecond { t.Errorf("Execution took: %v", execTime) } Guardian.lkMux.Lock() @@ -116,7 +116,7 @@ func TestGuardianGuardIDs(t *testing.T) { } } Guardian.lkMux.Unlock() - secLockDur := time.Duration(1 * time.Millisecond) + secLockDur := time.Millisecond // second lock to test counter go Guardian.GuardIDs("", secLockDur, lockIDs[1:]...) time.Sleep(30 * time.Microsecond) // give time for goroutine to lock @@ -158,7 +158,7 @@ func TestGuardianGuardIDs(t *testing.T) { if totalLockDur := time.Now().Sub(tStart); totalLockDur < lockDur { t.Errorf("Lock duration too small") } - time.Sleep(time.Duration(30) * time.Millisecond) + time.Sleep(30 * time.Millisecond) // making sure the items stay locked Guardian.lkMux.Lock() if len(Guardian.locks) != 3 { @@ -220,7 +220,7 @@ func TestGuardianGuardIDsTimeoutConcurrent(t *testing.T) { for i := 0; i < maxIter; i++ { sg.Add(1) go func() { - Guardian.GuardIDs(refID, time.Duration(time.Microsecond), keys...) + Guardian.GuardIDs(refID, time.Microsecond, keys...) sg.Done() }() } diff --git a/loaders/loader_test.go b/loaders/loader_test.go index 317c1ed83..2a47cd593 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -292,7 +292,7 @@ func TestLoaderProcessResource(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, - UsageTTL: time.Duration(1 * time.Second), + UsageTTL: time.Second, AllocationMessage: "call", Weight: 10, Limit: 2, @@ -307,7 +307,7 @@ func TestLoaderProcessResource(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, - UsageTTL: time.Duration(3600 * time.Second), + UsageTTL: 3600 * time.Second, AllocationMessage: "premium_call", Weight: 10, Limit: 2, @@ -539,7 +539,7 @@ func TestLoaderProcessThresholds(t *testing.T) { ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC)}, MaxHits: 12, MinHits: 10, - MinSleep: time.Duration(1 * time.Second), + MinSleep: time.Second, Blocker: true, Weight: 10, ActionIDs: []string{"THRESH1"}, @@ -646,7 +646,7 @@ func TestLoaderProcessStats(t *testing.T) { ActivationTime: time.Date(2014, 7, 29, 15, 00, 0, 0, time.UTC), }, QueueLength: 100, - TTL: time.Duration(1 * time.Second), + TTL: time.Second, Metrics: []*engine.MetricWithFilters{ { MetricID: "*sum#~*req.Value", @@ -1364,16 +1364,16 @@ func TestLoaderProcessRateProfile(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1383,10 +1383,10 @@ func TestLoaderProcessRateProfile(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1396,10 +1396,10 @@ func TestLoaderProcessRateProfile(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1551,16 +1551,16 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1606,16 +1606,16 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1625,10 +1625,10 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1638,10 +1638,10 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1702,16 +1702,16 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1721,10 +1721,10 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1734,10 +1734,10 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1764,16 +1764,16 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1783,10 +1783,10 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1796,10 +1796,10 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1852,16 +1852,16 @@ cgrates.org,RP1, ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1871,10 +1871,10 @@ cgrates.org,RP1, ActivationTimes: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, @@ -1921,16 +1921,16 @@ cgrates.org,RP1, ActivationTimes: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0 * time.Second), + IntervalStart: 0, Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, { - IntervalStart: time.Duration(1 * time.Minute), + IntervalStart: time.Minute, Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, }, diff --git a/migrator/attributes_test.go b/migrator/attributes_test.go index 3482d873e..f92d7787b 100644 --- a/migrator/attributes_test.go +++ b/migrator/attributes_test.go @@ -28,7 +28,7 @@ import ( ) func TestV1AttributeProfileAsAttributeProfile(t *testing.T) { - cloneExpTime := time.Now().Add(time.Duration(20 * time.Minute)) + cloneExpTime := time.Now().Add(20 * time.Minute) mapSubstitutes := make(map[string]map[string]*v1Attribute) mapSubstitutes["FL1"] = make(map[string]*v1Attribute) mapSubstitutes["FL1"]["In1"] = &v1Attribute{ @@ -76,7 +76,7 @@ func TestV1AttributeProfileAsAttributeProfile(t *testing.T) { } func TestV2AttributeProfileAsAttributeProfile(t *testing.T) { - cloneExpTime := time.Now().Add(time.Duration(20 * time.Minute)) + cloneExpTime := time.Now().Add(20 * time.Minute) v2Attribute := v2AttributeProfile{ Tenant: "cgrates.org", ID: "attributeprofile1", @@ -122,7 +122,7 @@ func TestV2AttributeProfileAsAttributeProfile(t *testing.T) { } func TestV2AttributeProfileAsAttributeProfile2(t *testing.T) { - cloneExpTime := time.Now().Add(time.Duration(20 * time.Minute)) + cloneExpTime := time.Now().Add(20 * time.Minute) v2Attribute := v2AttributeProfile{ Tenant: "cgrates.org", ID: "attributeprofile1", @@ -168,7 +168,7 @@ func TestV2AttributeProfileAsAttributeProfile2(t *testing.T) { } func TestV3AttributeProfileAsAttributeProfile(t *testing.T) { - cloneExpTime := time.Now().Add(time.Duration(20 * time.Minute)) + cloneExpTime := time.Now().Add(20 * time.Minute) v3Attribute := v3AttributeProfile{ Tenant: "cgrates.org", ID: "attributeprofile1", @@ -214,7 +214,7 @@ func TestV3AttributeProfileAsAttributeProfile(t *testing.T) { } func TestV4AttributeProfileAsAttributeProfile(t *testing.T) { - cloneExpTime := time.Now().Add(time.Duration(20 * time.Minute)) + cloneExpTime := time.Now().Add(20 * time.Minute) v4Attribute := v4AttributeProfile{ Tenant: "cgrates.org", ID: "attributeprofile1", diff --git a/migrator/cdrs_it_test.go b/migrator/cdrs_it_test.go index ddfdcc5be..bc872c887 100755 --- a/migrator/cdrs_it_test.go +++ b/migrator/cdrs_it_test.go @@ -146,7 +146,7 @@ func testCdrITMigrateAndMove(t *testing.T) { SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.MetaDefault, - Usage: time.Duration(10), + Usage: 10, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, Rated: true, diff --git a/migrator/rateprofiles_it_test.go b/migrator/rateprofiles_it_test.go index 83f188fdf..3ddd6fa81 100644 --- a/migrator/rateprofiles_it_test.go +++ b/migrator/rateprofiles_it_test.go @@ -197,8 +197,8 @@ func testRatePrfITMigrateAndMove(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { Value: 0.12, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Minute), + Unit: time.Minute, + Increment: time.Minute, }, }, Blocker: false, @@ -210,8 +210,8 @@ func testRatePrfITMigrateAndMove(t *testing.T) { IntervalRates: []*engine.IntervalRate{ { Value: 0.06, - Unit: time.Duration(1 * time.Minute), - Increment: time.Duration(1 * time.Second), + Unit: time.Minute, + Increment: time.Second, }, }, Blocker: false, diff --git a/migrator/session_costs_it_test.go b/migrator/session_costs_it_test.go index 4a80d9991..b003aefe7 100755 --- a/migrator/session_costs_it_test.go +++ b/migrator/session_costs_it_test.go @@ -181,7 +181,7 @@ func testSessionCostITMigrate(t *testing.T) { OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RunID: utils.MetaDefault, - Usage: time.Duration(10), + Usage: 10, CostSource: utils.MetaSessionS, CostDetails: cc, } diff --git a/migrator/stats_it_test.go b/migrator/stats_it_test.go index 98b922857..a200d42b7 100755 --- a/migrator/stats_it_test.go +++ b/migrator/stats_it_test.go @@ -145,10 +145,10 @@ func testStsITMigrateAndMove(t *testing.T) { tim := time.Date(2012, time.February, 27, 23, 59, 59, 0, time.UTC) var filters []*engine.FilterRule v1Sts := &v1Stat{ - Id: "test", // Config id, unique per config instance - QueueLength: 10, // Number of items in the stats buffer - TimeWindow: time.Duration(1) * time.Second, // Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow - SaveInterval: time.Duration(1) * time.Second, + Id: "test", // Config id, unique per config instance + QueueLength: 10, // Number of items in the stats buffer + TimeWindow: time.Second, // Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow + SaveInterval: time.Second, Metrics: []string{"ASR", "ACD", "ACC"}, SetupInterval: []time.Time{time.Now()}, ToR: []string{}, @@ -161,8 +161,8 @@ func testStsITMigrateAndMove(t *testing.T) { Account: []string{}, Subject: []string{}, DestinationIds: []string{}, - UsageInterval: []time.Duration{1 * time.Second}, - PddInterval: []time.Duration{1 * time.Second}, + UsageInterval: []time.Duration{time.Second}, + PddInterval: []time.Duration{time.Second}, Supplier: []string{}, DisconnectCause: []string{}, MediationRunIds: []string{}, @@ -208,15 +208,15 @@ func testStsITMigrateAndMove(t *testing.T) { ID: "test", FilterIDs: []string{v1Sts.Id}, QueueLength: 10, - TTL: time.Duration(0) * time.Second, + TTL: 0, Metrics: []*engine.MetricWithFilters{ - &engine.MetricWithFilters{ + { MetricID: "*asr", }, - &engine.MetricWithFilters{ + { MetricID: utils.MetaACD, }, - &engine.MetricWithFilters{ + { MetricID: "*acc", }, }, @@ -332,8 +332,8 @@ func testStsITMigrateFromv1(t *testing.T) { v1Sts := &v1Stat{ Id: "test", QueueLength: 10, - TimeWindow: time.Duration(1) * time.Second, - SaveInterval: time.Duration(1) * time.Second, + TimeWindow: time.Second, + SaveInterval: time.Second, Metrics: []string{"ASR", "ACD", "ACC"}, SetupInterval: []time.Time{tim}, ToR: []string{}, @@ -346,8 +346,8 @@ func testStsITMigrateFromv1(t *testing.T) { Account: []string{}, Subject: []string{}, DestinationIds: []string{}, - UsageInterval: []time.Duration{1 * time.Second}, - PddInterval: []time.Duration{1 * time.Second}, + UsageInterval: []time.Duration{time.Second}, + PddInterval: []time.Duration{time.Second}, Supplier: []string{}, DisconnectCause: []string{}, MediationRunIds: []string{}, diff --git a/migrator/stats_test.go b/migrator/stats_test.go index a71fc2cec..06c354545 100644 --- a/migrator/stats_test.go +++ b/migrator/stats_test.go @@ -31,10 +31,10 @@ func TestV1StatsAsStats(t *testing.T) { tim := time.Date(0001, time.January, 1, 2, 0, 0, 0, time.UTC) var filters []*engine.FilterRule v1Sts := &v1Stat{ - Id: "test", // Config id, unique per config instance - QueueLength: 10, // Number of items in the stats buffer - TimeWindow: time.Duration(1) * time.Second, // Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow - SaveInterval: time.Duration(1) * time.Second, + Id: "test", // Config id, unique per config instance + QueueLength: 10, // Number of items in the stats buffer + TimeWindow: time.Second, // Will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow + SaveInterval: time.Second, Metrics: []string{"ASR", "ACD", "ACC"}, SetupInterval: []time.Time{time.Now()}, ToR: []string{}, @@ -47,8 +47,8 @@ func TestV1StatsAsStats(t *testing.T) { Account: []string{}, Subject: []string{}, DestinationIds: []string{}, - UsageInterval: []time.Duration{1 * time.Second}, - PddInterval: []time.Duration{1 * time.Second}, + UsageInterval: []time.Duration{time.Second}, + PddInterval: []time.Duration{time.Second}, Supplier: []string{}, DisconnectCause: []string{}, MediationRunIds: []string{}, @@ -90,15 +90,15 @@ func TestV1StatsAsStats(t *testing.T) { ID: "test", FilterIDs: []string{v1Sts.Id}, QueueLength: 10, - TTL: time.Duration(0) * time.Second, + TTL: 0, Metrics: []*engine.MetricWithFilters{ - &engine.MetricWithFilters{ + { MetricID: "*asr", }, - &engine.MetricWithFilters{ + { MetricID: utils.MetaACD, }, - &engine.MetricWithFilters{ + { MetricID: "*acc", }, }, diff --git a/migrator/thresholds_it_test.go b/migrator/thresholds_it_test.go index af391f589..7158ebbc5 100644 --- a/migrator/thresholds_it_test.go +++ b/migrator/thresholds_it_test.go @@ -186,8 +186,8 @@ func testTrsITMigrateAndMove(t *testing.T) { UniqueID: "testUUID", // individual id ThresholdType: "*min_event_counter", //*min_event_counter, *max_event_counter, *min_balance_counter, *max_balance_counter, *min_balance, *max_balance, *balance_expired ThresholdValue: 5.32, - Recurrent: false, // reset excuted flag each run - MinSleep: time.Duration(5) * time.Second, // Minimum duration between two executions in case of recurrent triggers + Recurrent: false, // reset excuted flag each run + MinSleep: 5 * time.Second, // Minimum duration between two executions in case of recurrent triggers ExpirationDate: tim, ActivationDate: tim, Balance: &engine.BalanceFilter{ @@ -220,7 +220,7 @@ func testTrsITMigrateAndMove(t *testing.T) { }, Recurrent: true, MinHits: 0, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{}, @@ -236,7 +236,7 @@ func testTrsITMigrateAndMove(t *testing.T) { }, MaxHits: -1, MinHits: 0, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{}, @@ -252,7 +252,7 @@ func testTrsITMigrateAndMove(t *testing.T) { }, Recurrent: false, MinHits: 0, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{}, @@ -268,7 +268,7 @@ func testTrsITMigrateAndMove(t *testing.T) { }, MaxHits: 1, MinHits: 0, - MinSleep: time.Duration(5 * time.Minute), + MinSleep: 5 * time.Minute, Blocker: false, Weight: 20.0, ActionIDs: []string{}, diff --git a/migrator/thresholds_test.go b/migrator/thresholds_test.go index 66cdcee49..77336903b 100644 --- a/migrator/thresholds_test.go +++ b/migrator/thresholds_test.go @@ -34,8 +34,8 @@ func Testv2ActionTriggerAsThreshold(t *testing.T) { UniqueID: "testUUID", // individual id ThresholdType: "*min_event_counter", //*min_event_counter, *max_event_counter, *min_balance_counter, *max_balance_counter, *min_balance, *max_balance, *balance_expired ThresholdValue: 5.32, - Recurrent: false, // reset excuted flag each run - MinSleep: time.Duration(5) * time.Second, // Minimum duration between two executions in case of recurrent triggers + Recurrent: false, // reset excuted flag each run + MinSleep: 5 * time.Second, // Minimum duration between two executions in case of recurrent triggers ExpirationDate: time.Now(), ActivationDate: time.Now(), Balance: new(engine.BalanceFilter), diff --git a/rates/librates_test.go b/rates/librates_test.go index bf5f5c81a..34536c910 100644 --- a/rates/librates_test.go +++ b/rates/librates_test.go @@ -34,7 +34,7 @@ func TestOrderRatesOnIntervals(t *testing.T) { Weight: 0, IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, } @@ -45,7 +45,7 @@ func TestOrderRatesOnIntervals(t *testing.T) { Weight: 50, IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, } @@ -53,13 +53,13 @@ func TestOrderRatesOnIntervals(t *testing.T) { allRts := []*engine.Rate{rt0, rtChristmas} expOrdered := []*orderedRate{ { - time.Duration(0), + 0, rt0, }, } sTime := time.Date(2020, time.June, 28, 18, 56, 05, 0, time.UTC) - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute if ordRts, err := orderRatesOnIntervals( allRts, sTime, usage, true, 10); err != nil { t.Error(err) @@ -70,16 +70,16 @@ func TestOrderRatesOnIntervals(t *testing.T) { expOrdered = []*orderedRate{ { - time.Duration(0), + 0, rt0, }, { - time.Duration(55 * time.Second), + 55 * time.Second, rtChristmas, }, } sTime = time.Date(2020, time.December, 23, 23, 59, 05, 0, time.UTC) - usage = time.Duration(2 * time.Minute) + usage = 2 * time.Minute if ordRts, err := orderRatesOnIntervals( allRts, sTime, usage, true, 10); err != nil { t.Error(err) @@ -90,20 +90,20 @@ func TestOrderRatesOnIntervals(t *testing.T) { expOrdered = []*orderedRate{ { - time.Duration(0), + 0, rt0, }, { - time.Duration(55 * time.Second), + 55 * time.Second, rtChristmas, }, { - time.Duration(86455 * time.Second), + 86455 * time.Second, rt0, }, } sTime = time.Date(2020, time.December, 23, 23, 59, 05, 0, time.UTC) - usage = time.Duration(25 * time.Hour) + usage = 25 * time.Hour if ordRts, err := orderRatesOnIntervals( allRts, sTime, usage, true, 10); err != nil { t.Error(err) @@ -115,7 +115,7 @@ func TestOrderRatesOnIntervals(t *testing.T) { rts := []*engine.Rate{rtChristmas} expOrdered = nil sTime = time.Date(2020, time.December, 25, 23, 59, 05, 0, time.UTC) - usage = time.Duration(2 * time.Minute) + usage = 2 * time.Minute if ordRts, err := orderRatesOnIntervals( rts, sTime, usage, true, 10); err != nil { t.Error(err) @@ -307,14 +307,14 @@ func TestOrderRatesOnIntervalsEveryTwentyFiveMins(t *testing.T) { } } sTime := time.Date(2020, 10, 28, 20, 0, 0, 0, time.UTC) - usage := 1 * time.Hour + usage := time.Hour expected := []*orderedRate{ { 0, rtTwentyFiveMins, }, { - 1 * time.Minute, + time.Minute, rt1, }, { @@ -379,7 +379,7 @@ func TestOrderRatesOnIntervalsOneMinutePause(t *testing.T) { } } sTime := time.Date(2020, 10, 28, 20, 0, 0, 0, time.UTC) - usage := 1 * time.Hour + usage := time.Hour expected := []*orderedRate{ { 0, @@ -695,7 +695,7 @@ func TestOrderRateOnIntervalsTwoRatesInOne(t *testing.T) { usage := 25 * time.Hour expected := []*orderedRate{ { - 1 * time.Hour, + time.Hour, rtHalfDay1, }, { @@ -753,7 +753,7 @@ func TestOrderRateOnIntervalsEvery1Hour30Mins(t *testing.T) { rateEvery30Mins, }, { - 1 * time.Minute, + time.Minute, rateEvery1H, }, { @@ -952,14 +952,14 @@ func TestOrderRatesOnIntervalsEvenOddMinutes(t *testing.T) { } } sTime := time.Date(2020, 12, 23, 22, 0, 0, 0, time.UTC) - usage := 5*time.Minute + 1*time.Second + usage := 5*time.Minute + time.Second expected := []*orderedRate{ { 0, rtEvenMinutes, }, { - 1 * time.Minute, + time.Minute, rtOddMInutes, }, { @@ -1109,7 +1109,7 @@ func TestOrderOnRatesIntervalsEveryTwoHours(t *testing.T) { rt1, }, { - 1*time.Hour + 50*time.Minute, + time.Hour + 50*time.Minute, rtEvTwoHours, }, { @@ -1230,7 +1230,7 @@ func TestOrderRatesOnIntervalsSpecialHour(t *testing.T) { usage := 11 * time.Hour expected := []*orderedRate{ { - 1 * time.Hour, + time.Hour, rtRestricted, }, { @@ -1421,7 +1421,7 @@ func TestOrderRatesOnIntervalCaseMaxIterations(t *testing.T) { ActivationTimes: "1 * * * *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, } @@ -1444,7 +1444,7 @@ func TestOrderRatesOnIntervalIsDirectionFalse(t *testing.T) { ActivationTimes: "* * 27 02 *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, } @@ -1454,7 +1454,7 @@ func TestOrderRatesOnIntervalIsDirectionFalse(t *testing.T) { } expected := []*orderedRate{ { - time.Duration(0), + 0, rt1, }, } @@ -1478,7 +1478,7 @@ func TestOrderRatesOnIntervalWinnNill(t *testing.T) { ActivationTimes: "* * 1 * *", IntervalRates: []*engine.IntervalRate{ { - IntervalStart: time.Duration(0), + IntervalStart: 0, }, }, } @@ -1488,7 +1488,7 @@ func TestOrderRatesOnIntervalWinnNill(t *testing.T) { } expected := []*orderedRate{ { - time.Duration(0), + 0, rt1, }, } @@ -1522,7 +1522,7 @@ func TestOrderRatesOnIntervalIntervalStartHigherThanEndIdx(t *testing.T) { } expected := []*orderedRate{ { - time.Duration(0), + 0, rt1, }, } @@ -1557,7 +1557,7 @@ func TestOrderRatesOnIntervalStartLowerThanEndIdx(t *testing.T) { } expected := []*orderedRate{ { - time.Duration(0), + 0, rt1, }, } diff --git a/scheduler/scheduler_test.go b/scheduler/scheduler_test.go index e8023fcb4..0f093a6b9 100644 --- a/scheduler/scheduler_test.go +++ b/scheduler/scheduler_test.go @@ -26,7 +26,7 @@ import ( ) func TestSchedulerUpdateActStats(t *testing.T) { - sched := &Scheduler{actStatsInterval: 1 * time.Millisecond, actSuccessStats: make(map[string]map[time.Time]bool)} + sched := &Scheduler{actStatsInterval: time.Millisecond, actSuccessStats: make(map[string]map[time.Time]bool)} sched.updateActStats(&engine.Action{Id: "REMOVE_1", ActionType: utils.REMOVE_ACCOUNT}, false) if len(sched.actSuccessStats[utils.REMOVE_ACCOUNT]) != 1 { t.Errorf("Wrong stats: %+v", sched.actSuccessStats[utils.REMOVE_ACCOUNT]) diff --git a/sessions/session_test.go b/sessions/session_test.go index e415e4ca3..6ddd9062c 100644 --- a/sessions/session_test.go +++ b/sessions/session_test.go @@ -80,22 +80,22 @@ func TestSessionClone(t *testing.T) { ResourceID: "resourceID", ClientConnID: "ClientConnID", EventStart: engine.NewMapEvent(nil), - DebitInterval: time.Duration(18), + DebitInterval: 18, SRuns: []*SRun{ {Event: engine.NewMapEvent(nil), CD: &engine.CallDescriptor{Category: "test"}, EventCost: &engine.EventCost{CGRID: "testCGRID"}, - ExtraDuration: time.Duration(1), - LastUsage: time.Duration(2), - TotalUsage: time.Duration(3), + ExtraDuration: 1, + LastUsage: 2, + TotalUsage: 3, NextAutoDebit: &tTime, }, {Event: engine.NewMapEvent(nil), CD: &engine.CallDescriptor{Category: "test2"}, EventCost: &engine.EventCost{CGRID: "testCGRID2"}, - ExtraDuration: time.Duration(4), - LastUsage: time.Duration(5), - TotalUsage: time.Duration(6), + ExtraDuration: 4, + LastUsage: 5, + TotalUsage: 6, NextAutoDebit: &tTime2, }, }, @@ -106,22 +106,22 @@ func TestSessionClone(t *testing.T) { ResourceID: "resourceID", ClientConnID: "ClientConnID", EventStart: engine.NewMapEvent(nil), - DebitInterval: time.Duration(18), + DebitInterval: 18, SRuns: []*SRun{ {Event: engine.NewMapEvent(nil), CD: &engine.CallDescriptor{Category: "test"}, EventCost: &engine.EventCost{CGRID: "testCGRID"}, - ExtraDuration: time.Duration(1), - LastUsage: time.Duration(2), - TotalUsage: time.Duration(3), + ExtraDuration: 1, + LastUsage: 2, + TotalUsage: 3, NextAutoDebit: &tTime, }, {Event: engine.NewMapEvent(nil), CD: &engine.CallDescriptor{Category: "test2"}, EventCost: &engine.EventCost{CGRID: "testCGRID2"}, - ExtraDuration: time.Duration(4), - LastUsage: time.Duration(5), - TotalUsage: time.Duration(6), + ExtraDuration: 4, + LastUsage: 5, + TotalUsage: 6, NextAutoDebit: &tTime2, }, }, @@ -136,9 +136,9 @@ func TestSessionClone(t *testing.T) { if session.CGRID == "newCGRID" { t.Errorf("Expecting: CGRID, received: newCGRID") } - rcv.SRuns[1].TotalUsage = time.Duration(10) - if session.SRuns[1].TotalUsage == time.Duration(10) { - t.Errorf("Expecting: %s, received: %s", time.Duration(3), time.Duration(10)) + rcv.SRuns[1].TotalUsage = 10 + if session.SRuns[1].TotalUsage == 10 { + t.Errorf("Expecting: %s, received: %s", 3*time.Nanosecond, session.SRuns[1].TotalUsage) } tTimeNow := time.Now() *rcv.SRuns[1].NextAutoDebit = tTimeNow @@ -153,10 +153,10 @@ func TestSessionClone(t *testing.T) { //Test1 ExtraDuration 0 and LastUsage < initial func TestSRunDebitReserve(t *testing.T) { - lastUsage := time.Duration(1*time.Minute + 30*time.Second) - duration := time.Duration(2 * time.Minute) + lastUsage := time.Minute + 30*time.Second + duration := 2 * time.Minute sr := &SRun{ - ExtraDuration: time.Duration(0), + ExtraDuration: 0, LastUsage: duration, TotalUsage: duration, } @@ -164,8 +164,8 @@ func TestSRunDebitReserve(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", lastUsage, rDur) } //start with extraDuration 0 and the difference go in rDur - if sr.ExtraDuration != time.Duration(0) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(0), sr.ExtraDuration) + if sr.ExtraDuration != 0 { + t.Errorf("Expecting: %+v, received: %+v", 0, sr.ExtraDuration) } if sr.LastUsage != lastUsage { t.Errorf("Expecting: %+v, received: %+v", lastUsage, sr.LastUsage) @@ -177,18 +177,18 @@ func TestSRunDebitReserve(t *testing.T) { //Test2 ExtraDuration 0 and LastUsage > initial func TestSRunDebitReserve2(t *testing.T) { - lastUsage := time.Duration(2*time.Minute + 30*time.Second) - duration := time.Duration(2 * time.Minute) + lastUsage := 2*time.Minute + 30*time.Second + duration := 2 * time.Minute sr := &SRun{ - ExtraDuration: time.Duration(0), + ExtraDuration: 0, LastUsage: duration, TotalUsage: duration, } if rDur := sr.debitReserve(duration, &lastUsage); rDur != lastUsage { t.Errorf("Expecting: %+v, received: %+v", lastUsage, rDur) } - if sr.ExtraDuration != time.Duration(0) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(0), sr.ExtraDuration) + if sr.ExtraDuration != 0 { + t.Errorf("Expecting: %+v, received: %+v", 0, sr.ExtraDuration) } if sr.LastUsage != lastUsage { t.Errorf("Expecting: %+v, received: %+v", lastUsage, sr.LastUsage) @@ -200,18 +200,18 @@ func TestSRunDebitReserve2(t *testing.T) { //Test3 ExtraDuration ( 1m < duration) and LastUsage < initial func TestSRunDebitReserve3(t *testing.T) { - lastUsage := time.Duration(1*time.Minute + 30*time.Second) - duration := time.Duration(2 * time.Minute) + lastUsage := time.Minute + 30*time.Second + duration := 2 * time.Minute sr := &SRun{ - ExtraDuration: time.Duration(time.Minute), + ExtraDuration: time.Minute, LastUsage: duration, TotalUsage: duration, } if rDur := sr.debitReserve(duration, &lastUsage); rDur != (duration - lastUsage) { t.Errorf("Expecting: %+v, received: %+v", lastUsage, rDur) } - if sr.ExtraDuration != time.Duration(0) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(0), sr.ExtraDuration) + if sr.ExtraDuration != 0 { + t.Errorf("Expecting: %+v, received: %+v", 0, sr.ExtraDuration) } if sr.LastUsage != lastUsage { t.Errorf("Expecting: %+v, received: %+v", lastUsage, sr.LastUsage) @@ -223,19 +223,19 @@ func TestSRunDebitReserve3(t *testing.T) { //Test4 ExtraDuration 1m and LastUsage > initial func TestSRunDebitReserve4(t *testing.T) { - lastUsage := time.Duration(2*time.Minute + 30*time.Second) - duration := time.Duration(2 * time.Minute) + lastUsage := 2*time.Minute + 30*time.Second + duration := 2 * time.Minute sr := &SRun{ - ExtraDuration: time.Duration(time.Minute), + ExtraDuration: time.Minute, LastUsage: duration, TotalUsage: duration, } //We have extraDuration 1 minute and 30s different - if rDur := sr.debitReserve(duration, &lastUsage); rDur != time.Duration(1*time.Minute+30*time.Second) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(1*time.Minute+30*time.Second), rDur) + if rDur := sr.debitReserve(duration, &lastUsage); rDur != time.Minute+30*time.Second { + t.Errorf("Expecting: %+v, received: %+v", time.Minute+30*time.Second, rDur) } - if sr.ExtraDuration != time.Duration(0) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(0), sr.ExtraDuration) + if sr.ExtraDuration != 0 { + t.Errorf("Expecting: %+v, received: %+v", 0, sr.ExtraDuration) } if sr.LastUsage != lastUsage { t.Errorf("Expecting: %+v, received: %+v", lastUsage, sr.LastUsage) @@ -247,54 +247,54 @@ func TestSRunDebitReserve4(t *testing.T) { //Test5 ExtraDuration 3m ( > initialDuration) and LastUsage < initial func TestSRunDebitReserve5(t *testing.T) { - lastUsage := time.Duration(1*time.Minute + 30*time.Second) - duration := time.Duration(2 * time.Minute) + lastUsage := time.Minute + 30*time.Second + duration := 2 * time.Minute sr := &SRun{ - ExtraDuration: time.Duration(3 * time.Minute), + ExtraDuration: 3 * time.Minute, LastUsage: duration, TotalUsage: duration, } //in debit reserve we start with an extraDuration 3m //after we add the different dur-lastUsed (+30s) - if rDur := sr.debitReserve(duration, &lastUsage); rDur != time.Duration(0) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(0), rDur) + if rDur := sr.debitReserve(duration, &lastUsage); rDur != 0 { + t.Errorf("Expecting: %+v, received: %+v", 0, rDur) } //ExtraDuration (3m30s - 2m) - if sr.ExtraDuration != time.Duration(1*time.Minute+30*time.Second) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(1*time.Minute+30*time.Second), sr.ExtraDuration) + if sr.ExtraDuration != time.Minute+30*time.Second { + t.Errorf("Expecting: %+v, received: %+v", time.Minute+30*time.Second, sr.ExtraDuration) } if sr.LastUsage != duration { t.Errorf("Expecting: %+v, received: %+v", duration, sr.LastUsage) } - if sr.TotalUsage != time.Duration(3*time.Minute+30*time.Second) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(3*time.Minute+30*time.Second), sr.TotalUsage) + if sr.TotalUsage != 3*time.Minute+30*time.Second { + t.Errorf("Expecting: %+v, received: %+v", 3*time.Minute+30*time.Second, sr.TotalUsage) } } //Test6 ExtraDuration 3m ( > initialDuration) and LastUsage > initial func TestSRunDebitReserve6(t *testing.T) { - lastUsage := time.Duration(2*time.Minute + 30*time.Second) - duration := time.Duration(2 * time.Minute) + lastUsage := 2*time.Minute + 30*time.Second + duration := 2 * time.Minute sr := &SRun{ - ExtraDuration: time.Duration(3 * time.Minute), + ExtraDuration: 3 * time.Minute, LastUsage: duration, TotalUsage: duration, } //in debit reserve we start with an extraDuration 3m //after we add the different dur-lastUsed (-30s) - if rDur := sr.debitReserve(duration, &lastUsage); rDur != time.Duration(0) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(0), rDur) + if rDur := sr.debitReserve(duration, &lastUsage); rDur != 0 { + t.Errorf("Expecting: %+v, received: %+v", 0, rDur) } //ExtraDuration (2m30s - 2m) - if sr.ExtraDuration != time.Duration(30*time.Second) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(30*time.Second), sr.ExtraDuration) + if sr.ExtraDuration != 30*time.Second { + t.Errorf("Expecting: %+v, received: %+v", 30*time.Second, sr.ExtraDuration) } if sr.LastUsage != duration { t.Errorf("Expecting: %+v, received: %+v", duration, sr.LastUsage) } // 2m(initial Total) + 2m30s(correction) - if sr.TotalUsage != time.Duration(4*time.Minute+30*time.Second) { - t.Errorf("Expecting: %+v, received: %+v", time.Duration(4*time.Minute+30*time.Second), sr.TotalUsage) + if sr.TotalUsage != 4*time.Minute+30*time.Second { + t.Errorf("Expecting: %+v, received: %+v", 4*time.Minute+30*time.Second, sr.TotalUsage) } } @@ -311,7 +311,7 @@ func TestSessionAsCGREventsRawEvent(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.12, } s := &Session{ @@ -338,7 +338,7 @@ func TestSessionAsCGREvents(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.12, } ev := map[string]interface{}{ @@ -354,7 +354,7 @@ func TestSessionAsCGREvents(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.13, } s := &Session{ @@ -363,7 +363,7 @@ func TestSessionAsCGREvents(t *testing.T) { EventStart: engine.NewMapEvent(startEv), SRuns: []*SRun{{ Event: engine.NewMapEvent(ev), - TotalUsage: time.Duration(2 * time.Second), + TotalUsage: 2 * time.Second, }}, } //check for some fields if populated correct @@ -393,7 +393,7 @@ func TestSessionAsExternalSessions(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.12, } ev := map[string]interface{}{ @@ -409,7 +409,7 @@ func TestSessionAsExternalSessions(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.13, } tTime := time.Date(2020, time.April, 18, 23, 0, 0, 0, time.UTC) @@ -420,7 +420,7 @@ func TestSessionAsExternalSessions(t *testing.T) { DebitInterval: time.Second, SRuns: []*SRun{{ Event: engine.NewMapEvent(ev), - TotalUsage: time.Duration(2 * time.Second), + TotalUsage: 2 * time.Second, NextAutoDebit: &tTime, }}, } @@ -439,7 +439,7 @@ func TestSessionAsExternalSessions(t *testing.T) { Destination: "1004", SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, ExtraFields: map[string]string{ utils.EVENT_NAME: "TEST_EVENT2", }, @@ -473,7 +473,7 @@ func TestSessionAsExternalSessions2(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.12, } ev := map[string]interface{}{ @@ -489,7 +489,7 @@ func TestSessionAsExternalSessions2(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.13, } s := &Session{ @@ -499,7 +499,7 @@ func TestSessionAsExternalSessions2(t *testing.T) { DebitInterval: time.Second, SRuns: []*SRun{{ Event: engine.NewMapEvent(ev), - TotalUsage: time.Duration(2 * time.Second), + TotalUsage: 2 * time.Second, CD: &engine.CallDescriptor{ LoopIndex: 10, DurationIndex: 3 * time.Second, @@ -524,7 +524,7 @@ func TestSessionAsExternalSessions2(t *testing.T) { Destination: "1004", SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, ExtraFields: map[string]string{ utils.EVENT_NAME: "TEST_EVENT2", }, @@ -557,7 +557,7 @@ func TestSessionAsExternalSessions3(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.12, } ev := map[string]interface{}{ @@ -573,7 +573,7 @@ func TestSessionAsExternalSessions3(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.13, } tTime := time.Date(2020, time.April, 18, 23, 0, 0, 0, time.UTC) @@ -585,7 +585,7 @@ func TestSessionAsExternalSessions3(t *testing.T) { DebitInterval: time.Second, SRuns: []*SRun{{ Event: engine.NewMapEvent(ev), - TotalUsage: time.Duration(2 * time.Second), + TotalUsage: 2 * time.Second, CD: &engine.CallDescriptor{ LoopIndex: 10, DurationIndex: 3 * time.Second, @@ -611,7 +611,7 @@ func TestSessionAsExternalSessions3(t *testing.T) { Destination: "1004", SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - Usage: time.Duration(2 * time.Second), + Usage: 2 * time.Second, ExtraFields: map[string]string{ utils.EVENT_NAME: "TEST_EVENT2", }, @@ -649,29 +649,29 @@ func TestSessiontotalUsage(t *testing.T) { ResourceID: "resourceID", ClientConnID: "ClientConnID", EventStart: engine.NewMapEvent(nil), - DebitInterval: time.Duration(18), + DebitInterval: 18, SRuns: []*SRun{ { Event: engine.NewMapEvent(nil), CD: &engine.CallDescriptor{Category: "test"}, EventCost: &engine.EventCost{CGRID: "testCGRID"}, - ExtraDuration: time.Duration(1), - LastUsage: time.Duration(2), - TotalUsage: time.Duration(5), + ExtraDuration: 1, + LastUsage: 2, + TotalUsage: 5, NextAutoDebit: &tTime, }, { Event: engine.NewMapEvent(nil), CD: &engine.CallDescriptor{Category: "test2"}, EventCost: &engine.EventCost{CGRID: "testCGRID2"}, - ExtraDuration: time.Duration(4), - LastUsage: time.Duration(5), - TotalUsage: time.Duration(6), + ExtraDuration: 4, + LastUsage: 5, + TotalUsage: 6, NextAutoDebit: &tTime2, }, }, } - eOut = time.Duration(5) + eOut = 5 rcv = session.totalUsage() if !reflect.DeepEqual(eOut, rcv) { t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eOut), utils.ToJSON(rcv)) @@ -719,7 +719,7 @@ func TestUpdateSRuns(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.12, } ev := map[string]interface{}{ @@ -735,7 +735,7 @@ func TestUpdateSRuns(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(2 * time.Second), + utils.Usage: 2 * time.Second, utils.Cost: 12.13, } s := &Session{ @@ -745,7 +745,7 @@ func TestUpdateSRuns(t *testing.T) { DebitInterval: time.Second, SRuns: []*SRun{{ Event: engine.NewMapEvent(ev), - TotalUsage: time.Duration(2 * time.Second), + TotalUsage: 2 * time.Second, CD: &engine.CallDescriptor{ LoopIndex: 10, DurationIndex: 3 * time.Second, diff --git a/sessions/sessions_bench_test.go b/sessions/sessions_bench_test.go index b94dd181a..2683c2678 100644 --- a/sessions/sessions_bench_test.go +++ b/sessions/sessions_bench_test.go @@ -69,7 +69,7 @@ func loadTP() { attrs, &tpLoadInst); err != nil { log.Fatal(err) } - time.Sleep(time.Duration(100) * time.Millisecond) // Give time for scheduler to execute topups + time.Sleep(100 * time.Millisecond) // Give time for scheduler to execute topups } func addBalance(sBenchRPC *rpc.Client, sraccount string) { diff --git a/sessions/sessions_birpc_it_test.go b/sessions/sessions_birpc_it_test.go index 7d219320d..772c0f7f6 100644 --- a/sessions/sessions_birpc_it_test.go +++ b/sessions/sessions_birpc_it_test.go @@ -183,7 +183,7 @@ func testSessionsBiRPCSessionAutomaticDisconnects(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(200 * time.Millisecond), + utils.Usage: 200 * time.Millisecond, }, }, }, @@ -201,7 +201,7 @@ func testSessionsBiRPCSessionAutomaticDisconnects(t *testing.T) { } // Make sure we are receiving a disconnect event select { - case <-time.After(time.Duration(100 * time.Millisecond)): + case <-time.After(100 * time.Millisecond): t.Error("Did not receive disconnect event") case disconnectEv := <-disconnectEvChan: if engine.NewMapEvent(disconnectEv.EventStart).GetStringIgnoreErrors(utils.OriginID) != initArgs.CGREvent.Event[utils.OriginID] { @@ -237,7 +237,7 @@ func testSessionsBiRPCSessionAutomaticDisconnects(t *testing.T) { if err := sessionsBiRPC.Call(utils.SessionSv1TerminateSession, termArgs, &rpl); err != nil || rpl != utils.OK { t.Error(err) } - time.Sleep(time.Duration(100 * time.Millisecond)) // Give time for debits to occur + time.Sleep(100 * time.Millisecond) // Give time for debits to occur if err := sessionsRPC.Call(utils.APIerSv2GetAccount, attrGetAcnt, &acnt); err != nil { t.Error(err) } else if acnt.BalanceMap[utils.VOICE].GetTotalValue() != 0 { @@ -309,7 +309,7 @@ func testSessionsBiRPCSessionOriginatorTerminate(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(200 * time.Millisecond), + utils.Usage: 200 * time.Millisecond, }, }, }, @@ -326,7 +326,7 @@ func testSessionsBiRPCSessionOriginatorTerminate(t *testing.T) { t.Errorf("Expecting : %+v, received: %+v", expMaxUsage, initRpl.MaxUsage) } - time.Sleep(time.Duration(10 * time.Millisecond)) // Give time for debits to occur + time.Sleep(10 * time.Millisecond) // Give time for debits to occur termArgs := &V1TerminateSessionArgs{ TerminateSession: true, @@ -346,7 +346,7 @@ func testSessionsBiRPCSessionOriginatorTerminate(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(7 * time.Millisecond), + utils.Usage: 7 * time.Millisecond, }, }, }, @@ -357,7 +357,7 @@ func testSessionsBiRPCSessionOriginatorTerminate(t *testing.T) { t.Error(err) } - time.Sleep(time.Duration(50 * time.Millisecond)) // Give time for debits to occur + time.Sleep(50 * time.Millisecond) // Give time for debits to occur if err := sessionsRPC.Call(utils.APIerSv2GetAccount, attrGetAcnt, &acnt); err != nil { t.Error(err) } else if acnt.BalanceMap[utils.VOICE].GetTotalValue() > 0.995*float64(time.Second) { // FixMe: should be not 0.93? @@ -369,7 +369,7 @@ func testSessionsBiRPCSessionOriginatorTerminate(t *testing.T) { } else if reply != utils.OK { t.Errorf("Received reply: %s", reply) } - time.Sleep(time.Duration(10) * time.Millisecond) + time.Sleep(10 * time.Millisecond) var cdrs []*engine.ExternalCDR req := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, diff --git a/sessions/sessions_data_it_test.go b/sessions/sessions_data_it_test.go index 8675e86d5..66d6cf86b 100644 --- a/sessions/sessions_data_it_test.go +++ b/sessions/sessions_data_it_test.go @@ -141,7 +141,7 @@ func testSessionsDataLastUsedData(t *testing.T) { Account: "1001", Destination: utils.DATA, TimeStart: tStart, - TimeEnd: tStart.Add(time.Duration(1024)), + TimeEnd: tStart.Add(1024), } var cc engine.CallCost // Make sure the cost is what we expect to be for 1MB of data @@ -339,7 +339,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) { if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, new(utils.SessionFilter), &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || - aSessions[0].Usage != time.Duration(6144) { + aSessions[0].Usage != 6144 { t.Errorf("wrong active sessions: %f", aSessions[0].Usage.Seconds()) } @@ -387,7 +387,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) { if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, new(utils.SessionFilter), &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || - aSessions[0].Usage != time.Duration(15360) { + aSessions[0].Usage != 15360 { t.Errorf("wrong active sessions: %v", aSessions[0].Usage) } else if aSessions[0].ExtraFields["Extra1"] != "other" { t.Errorf("Expected: \"other\", received: %v", aSessions[0].ExtraFields["Extra1"]) @@ -437,7 +437,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) { if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, new(utils.SessionFilter), &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || - aSessions[0].Usage != time.Duration(13312) { // 14MB in used, 2MB extra reserved + aSessions[0].Usage != 13312 { // 14MB in used, 2MB extra reserved t.Errorf("wrong active sessions: %+v", aSessions[0].Usage) } else if aSessions[0].ExtraFields["Extra1"] != "other2" { t.Errorf("Expected: \"other2\", received: %v", aSessions[0].ExtraFields["Extra1"]) @@ -486,7 +486,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) { if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, new(utils.SessionFilter), &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || - aSessions[0].Usage != time.Duration(14336) { // 14MB in use + aSessions[0].Usage != 14336 { // 14MB in use t.Errorf("wrong active sessions: %v", aSessions[0].Usage) } @@ -536,7 +536,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) { t.Errorf("Received reply: %s", reply) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(20 * time.Millisecond) var cdrs []*engine.ExternalCDR req := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, diff --git a/sessions/sessions_it_test.go b/sessions/sessions_it_test.go index 040ae8387..a6d033337 100644 --- a/sessions/sessions_it_test.go +++ b/sessions/sessions_it_test.go @@ -130,7 +130,7 @@ func testSessionsItTerminatUnexist(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute termArgs := &V1TerminateSessionArgs{ TerminateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -207,7 +207,7 @@ func testSessionsItUpdateUnexist(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute updtArgs := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -417,7 +417,7 @@ func testSessionsItEventCostCompressing(t *testing.T) { initArgs, &initRpl); err != nil { t.Error(err) } - if initRpl.MaxUsage == nil || *initRpl.MaxUsage != time.Duration(1*time.Second) { + if initRpl.MaxUsage == nil || *initRpl.MaxUsage != time.Second { t.Errorf("received: %+v", initRpl.MaxUsage) } updateArgs := &V1UpdateSessionArgs{ diff --git a/sessions/sessions_rpl_it_test.go b/sessions/sessions_rpl_it_test.go index ab0bfa752..cc6f0c96b 100644 --- a/sessions/sessions_rpl_it_test.go +++ b/sessions/sessions_rpl_it_test.go @@ -139,7 +139,7 @@ func testSessionSRplInitiate(t *testing.T) { t.Error(err) } - usage := time.Duration(1*time.Minute + 30*time.Second) + usage := time.Minute + 30*time.Second argsInit := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -185,8 +185,8 @@ func testSessionSRplInitiate(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", utils.ToIJSON(aSessions)) - } else if aSessions[0].Usage != time.Duration(90)*time.Second { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(90)*time.Second, aSessions[0].Usage) + } else if aSessions[0].Usage != 90*time.Second { + t.Errorf("Expecting : %+v, received: %+v", 90*time.Second, aSessions[0].Usage) } //check if the session was created as passive session on slave @@ -200,14 +200,14 @@ func testSessionSRplInitiate(t *testing.T) { t.Error(err) } else if len(pSessions) != 1 { t.Errorf("PassiveSessions: %+v", pSessions) - } else if pSessions[0].Usage != time.Duration(90*time.Second) { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(90)*time.Second, pSessions[0].Usage) + } else if pSessions[0].Usage != 90*time.Second { + t.Errorf("Expecting : %+v, received: %+v", 90*time.Second, pSessions[0].Usage) } } func testSessionSRplUpdate(t *testing.T) { //update the session on slave so the session should became active - usage := time.Duration(1 * time.Minute) + usage := time.Minute argsUpdate := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -251,8 +251,8 @@ func testSessionSRplUpdate(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(150)*time.Second { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(150)*time.Second, aSessions[0].Usage) + } else if aSessions[0].Usage != 150*time.Second { + t.Errorf("Expecting : %+v, received: %+v", 150*time.Second, aSessions[0].Usage) } var pSessions []*ExternalSession @@ -282,8 +282,8 @@ func testSessionSRplUpdate(t *testing.T) { t.Errorf("PassiveSessions: %+v", pSessions) } else if pSessions[0].CGRID != cgrID { t.Errorf("PassiveSession: %+v", pSessions[0]) - } else if pSessions[0].Usage != time.Duration(150*time.Second) { - t.Errorf("Expecting : %+v, received: %+v", time.Duration(150)*time.Second, pSessions[0].Usage) + } else if pSessions[0].Usage != 150*time.Second { + t.Errorf("Expecting : %+v, received: %+v", 150*time.Second, pSessions[0].Usage) } } @@ -306,7 +306,7 @@ func testSessionSRplTerminate(t *testing.T) { utils.Category: "call", utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: time.Duration(2*time.Minute + 30*time.Second), + utils.Usage: 2*time.Minute + 30*time.Second, }, }, }, @@ -371,7 +371,7 @@ func testSessionSRplManualReplicate(t *testing.T) { utils.Category: "call", utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 1*time.Minute + 30*time.Second, + utils.Usage: time.Minute + 30*time.Second, }, }, }, @@ -395,7 +395,7 @@ func testSessionSRplManualReplicate(t *testing.T) { utils.Category: "call", utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 1*time.Minute + 30*time.Second, + utils.Usage: time.Minute + 30*time.Second, }, }, }, @@ -406,7 +406,7 @@ func testSessionSRplManualReplicate(t *testing.T) { if err := smgRplcMstrRPC.Call(utils.SessionSv1InitiateSession, args, &initRpl); err != nil { t.Error(err) } - if initRpl.MaxUsage == nil || *initRpl.MaxUsage != time.Duration(90*time.Second) { + if initRpl.MaxUsage == nil || *initRpl.MaxUsage != 90*time.Second { t.Error("Bad max usage: ", initRpl.MaxUsage) } } @@ -416,7 +416,7 @@ func testSessionSRplManualReplicate(t *testing.T) { t.Error(err) } else if len(aSessions) != 2 { t.Errorf("Unexpected number of sessions received: %+v", utils.ToJSON(aSessions)) - } else if aSessions[0].Usage != time.Duration(90)*time.Second && aSessions[1].Usage != time.Duration(90)*time.Second { + } else if aSessions[0].Usage != 90*time.Second && aSessions[1].Usage != 90*time.Second { t.Errorf("Received usage: %v", aSessions[0].Usage) } // Start slave, should not have any active session at beginning @@ -451,7 +451,7 @@ func testSessionSRplManualReplicate(t *testing.T) { t.Error(err) } else if len(aSessions) != 2 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(90)*time.Second { + } else if aSessions[0].Usage != 90*time.Second { t.Errorf("Received usage: %v", aSessions[0].Usage) } // kill master @@ -496,7 +496,7 @@ func testSessionSRplManualReplicate(t *testing.T) { t.Error(err) } else if len(aSessions) != 2 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(90)*time.Second { + } else if aSessions[0].Usage != 90*time.Second { t.Errorf("Received usage: %v", aSessions[0].Usage) } } diff --git a/sessions/sessions_voice_it_test.go b/sessions/sessions_voice_it_test.go index 13d2c0a50..eab7cfe84 100644 --- a/sessions/sessions_voice_it_test.go +++ b/sessions/sessions_voice_it_test.go @@ -126,7 +126,7 @@ func testSessionsVoiceTPFromFolder(t *testing.T) { } func testSessionsVoiceMonetaryRefund(t *testing.T) { - usage := time.Duration(1*time.Minute + 30*time.Second) + usage := time.Minute + 30*time.Second initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -168,7 +168,7 @@ func testSessionsVoiceMonetaryRefund(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage = time.Duration(time.Minute) + usage = time.Minute termArgs := &V1TerminateSessionArgs{ TerminateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -207,7 +207,7 @@ func testSessionsVoiceMonetaryRefund(t *testing.T) { } func testSessionsVoiceVoiceRefund(t *testing.T) { - usage := time.Duration(1*time.Minute + 30*time.Second) + usage := time.Minute + 30*time.Second initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -251,7 +251,7 @@ func testSessionsVoiceVoiceRefund(t *testing.T) { eAcntVal, acnt.BalanceMap[utils.VOICE].GetTotalValue()) } - usage = time.Duration(time.Minute) + usage = time.Minute termArgs := &V1TerminateSessionArgs{ TerminateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -296,7 +296,7 @@ func testSessionsVoiceMixedRefund(t *testing.T) { t.Error(err) } - usage := time.Duration(1*time.Minute + 30*time.Second) + usage := time.Minute + 30*time.Second initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -343,7 +343,7 @@ func testSessionsVoiceMixedRefund(t *testing.T) { eMoneyVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage = time.Duration(time.Minute) + usage = time.Minute termArgs := &V1TerminateSessionArgs{ TerminateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -397,7 +397,7 @@ func testSessionsVoiceLastUsed(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -438,7 +438,7 @@ func testSessionsVoiceLastUsed(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - lastUsage := time.Duration(1*time.Minute + 30*time.Second) + lastUsage := time.Minute + 30*time.Second updateArgs := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -477,7 +477,7 @@ func testSessionsVoiceLastUsed(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - lastUsage = time.Duration(2*time.Minute + 30*time.Second) + lastUsage = 2*time.Minute + 30*time.Second updateArgs = &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -517,7 +517,7 @@ func testSessionsVoiceLastUsed(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage = time.Duration(1 * time.Minute) + usage = time.Minute termArgs := &V1TerminateSessionArgs{ TerminateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -566,7 +566,7 @@ func testSessionsVoiceLastUsedEnd(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -607,7 +607,7 @@ func testSessionsVoiceLastUsedEnd(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - lastUsage := time.Duration(30 * time.Second) + lastUsage := 30 * time.Second updateArgs := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -694,7 +694,7 @@ func testSessionsVoiceLastUsedNotFixed(t *testing.T) { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -736,7 +736,7 @@ func testSessionsVoiceLastUsedNotFixed(t *testing.T) { } //Update - lastUsage := time.Duration(12 * time.Second) + lastUsage := 12 * time.Second updateArgs := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -823,7 +823,7 @@ func testSessionsVoiceSessionTTL(t *testing.T) { eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -854,7 +854,7 @@ func testSessionsVoiceSessionTTL(t *testing.T) { t.Error(err) } - time.Sleep(time.Duration(30 * time.Millisecond)) + time.Sleep(30 * time.Millisecond) if initRpl.MaxUsage == nil || *initRpl.MaxUsage != usage { t.Errorf("Expected: %+v, received: %+v", usage, initRpl.MaxUsage) } @@ -881,7 +881,7 @@ func testSessionsVoiceSessionTTL(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(120)*time.Second { + } else if aSessions[0].Usage != 120*time.Second { t.Errorf("Expecting 2m, received usage: %v", aSessions[0].Usage) } @@ -893,7 +893,7 @@ func testSessionsVoiceSessionTTL(t *testing.T) { } //Update - lastUsage := time.Duration(30 * time.Second) + lastUsage := 30 * time.Second updateArgs := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -921,7 +921,7 @@ func testSessionsVoiceSessionTTL(t *testing.T) { if err := sessionsRPC.Call(utils.SessionSv1UpdateSession, updateArgs, &updateRpl); err != nil { t.Fatal(err) } - time.Sleep(time.Duration(10 * time.Millisecond)) + time.Sleep(10 * time.Millisecond) if updateRpl.MaxUsage == nil || *updateRpl.MaxUsage != usage { t.Errorf("Expected: %+v, received: %+v", usage, updateRpl.MaxUsage) } @@ -936,7 +936,7 @@ func testSessionsVoiceSessionTTL(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(150)*time.Second { + } else if aSessions[0].Usage != 150*time.Second { t.Errorf("Expecting 2m30s, received usage: %v", aSessions[0].Usage) } @@ -1000,7 +1000,7 @@ func testSessionsVoiceSessionTTLWithRelocate(t *testing.T) { eAcntVal, acnt.BalanceMap[utils.VOICE].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -1030,7 +1030,7 @@ func testSessionsVoiceSessionTTLWithRelocate(t *testing.T) { initArgs, &initRpl); err != nil { t.Error(err) } - time.Sleep(time.Duration(20 * time.Millisecond)) + time.Sleep(20 * time.Millisecond) if initRpl.MaxUsage == nil || *initRpl.MaxUsage != usage { t.Errorf("Expected: %+v, received: %+v", usage, initRpl.MaxUsage) } @@ -1046,7 +1046,7 @@ func testSessionsVoiceSessionTTLWithRelocate(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(120)*time.Second { + } else if aSessions[0].Usage != 120*time.Second { t.Errorf("Expecting 2m, received usage: %v", aSessions[0].Usage) } eAcntVal = 180.0 * float64(time.Second) @@ -1058,7 +1058,7 @@ func testSessionsVoiceSessionTTLWithRelocate(t *testing.T) { } //Update - lastUsage := time.Duration(30 * time.Second) + lastUsage := 30 * time.Second updateArgs := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -1094,7 +1094,7 @@ func testSessionsVoiceSessionTTLWithRelocate(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", usage, updateRpl.MaxUsage) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(20 * time.Millisecond) if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions, utils.SessionFilter{ Filters: []string{ @@ -1105,7 +1105,7 @@ func testSessionsVoiceSessionTTLWithRelocate(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(150)*time.Second { + } else if aSessions[0].Usage != 150*time.Second { t.Errorf("Expecting 2m30s, received usage: %v", aSessions[0].Usage) } eAcntVal = 150.0 * float64(time.Second) @@ -1177,7 +1177,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { acnt.BalanceMap[utils.VOICE].GetTotalValue()) } - usage := time.Duration(2 * time.Minute) + usage := 2 * time.Minute initArgs := &V1InitSessionArgs{ InitSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -1211,7 +1211,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", usage, initRpl.MaxUsage) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(20 * time.Millisecond) var aSessions []*ExternalSession if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions, utils.SessionFilter{ @@ -1223,7 +1223,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(120)*time.Second { + } else if aSessions[0].Usage != 120*time.Second { t.Errorf("Expecting 2m, received usage: %v", aSessions[0].Usage) } eAcntVal = 180.0 * float64(time.Second) @@ -1235,7 +1235,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { } //Update - lastUsage := time.Duration(30 * time.Second) + lastUsage := 30 * time.Second updateArgs := &V1UpdateSessionArgs{ UpdateSession: true, CGREventWithOpts: &utils.CGREventWithOpts{ @@ -1271,7 +1271,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", usage, updateRpl.MaxUsage) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(20 * time.Millisecond) if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions, utils.SessionFilter{ Filters: []string{ @@ -1282,7 +1282,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { t.Error(err) } else if len(aSessions) != 1 { t.Errorf("Unexpected number of sessions received: %+v", aSessions) - } else if aSessions[0].Usage != time.Duration(150)*time.Second { + } else if aSessions[0].Usage != 150*time.Second { t.Errorf("Expecting 2m30s, received usage: %v", aSessions[0].Usage) } eAcntVal = 150.0 * float64(time.Second) @@ -1311,7 +1311,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { utils.RequestType: utils.META_PREPAID, utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 49, 0, time.UTC), utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC), - utils.Usage: time.Duration(time.Minute), + utils.Usage: time.Minute, }, }, }, @@ -1323,7 +1323,7 @@ func testSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { t.Error(err) } - time.Sleep(time.Duration(10) * time.Millisecond) + time.Sleep(10 * time.Millisecond) if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions, utils.SessionFilter{ Filters: []string{ diff --git a/utils/apitpdata_test.go b/utils/apitpdata_test.go index 028d8c5ef..c11f7df11 100644 --- a/utils/apitpdata_test.go +++ b/utils/apitpdata_test.go @@ -748,7 +748,7 @@ func TestArgRSv1ResourceUsageCloneCase2(t *testing.T) { }, }, UsageID: "randomID", - UsageTTL: DurationPointer(time.Duration(2)), + UsageTTL: DurationPointer(2), Units: 1.0, } if replyArgRsv1, err := newArgRSv1.RPCClone(); err != nil { @@ -768,7 +768,7 @@ func TestArgRSv1ResourceUsageCloneCase3(t *testing.T) { }, }, UsageID: "randomID", - UsageTTL: DurationPointer(time.Duration(2)), + UsageTTL: DurationPointer(2), Units: 1.0, clnb: true, } diff --git a/utils/cgrevent_test.go b/utils/cgrevent_test.go index 49733e5ca..d459d792e 100644 --- a/utils/cgrevent_test.go +++ b/utils/cgrevent_test.go @@ -34,7 +34,7 @@ func TestCGREventHasField(t *testing.T) { //normal check cgrEvent = &CGREvent{ Event: map[string]interface{}{ - Usage: time.Duration(20 * time.Second), + Usage: 20 * time.Second, }, } rcv = cgrEvent.HasField("Usage") @@ -53,7 +53,7 @@ func TestCGREventCheckMandatoryFields(t *testing.T) { } cgrEvent = &CGREvent{ Event: map[string]interface{}{ - Usage: time.Duration(20 * time.Second), + Usage: 20 * time.Second, "test1": 1, "test2": 2, "test3": 3, @@ -84,7 +84,7 @@ func TestCGREventFielAsString(t *testing.T) { //normal check cgrEvent = &CGREvent{ Event: map[string]interface{}{ - Usage: time.Duration(20 * time.Second), + Usage: 20 * time.Second, "test1": 1, "test2": 2, "test3": 3, @@ -106,7 +106,7 @@ func TestLibRoutesUsage(t *testing.T) { Tenant: "cgrates.org", ID: "supplierEvent1", Event: map[string]interface{}{ - Usage: time.Duration(20 * time.Second), + Usage: 20 * time.Second, }, } seErr := &CGREvent{ @@ -159,7 +159,7 @@ func TestCGREventFieldAsString(t *testing.T) { ID: "supplierEvent1", Event: map[string]interface{}{ "supplierprofile1": "Supplier", - "UsageInterval": time.Duration(1 * time.Second), + "UsageInterval": time.Second, "PddInterval": "1s", "Weight": 20.0, }, diff --git a/utils/chrgdincrement_test.go b/utils/chrgdincrement_test.go index 211079696..649553182 100644 --- a/utils/chrgdincrement_test.go +++ b/utils/chrgdincrement_test.go @@ -21,7 +21,7 @@ package utils /* func TestJSONMarshalUnmarshal(t *testing.T) { incrmt := &ChargedIncrement{ - Usage: time.Duration(1 * time.Hour), + Usage: time.Hour, Cost: NewDecimalFromFloat64(2.13), AccountingID: "abbsjweejrmdhfr", CompressFactor: 1, @@ -38,7 +38,7 @@ func TestJSONMarshalUnmarshal(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", incrmt, uIncrmnt) } incrmt = &ChargedIncrement{ - Usage: time.Duration(1 * time.Hour), + Usage: time.Hour, AccountingID: "abbsjweejrmdhfr", CompressFactor: 1, } diff --git a/utils/coreutils.go b/utils/coreutils.go index 80465f03b..499479629 100644 --- a/utils/coreutils.go +++ b/utils/coreutils.go @@ -874,7 +874,7 @@ func GetUrlRawArguments(dialURL string) (out map[string]string) { // WarnExecTime is used when we need to meassure the execution of specific functions // and warn when the total duration is higher than expected -// should be usually called with defer, ie: defer WarnExecTime(time.Now(), "MyTestFunc", time.Duration(2*time.Second)) +// should be usually called with defer, ie: defer WarnExecTime(time.Now(), "MyTestFunc", 2*time.Second) func WarnExecTime(startTime time.Time, logID string, maxDur time.Duration) { totalDur := time.Since(startTime) if totalDur > maxDur { diff --git a/utils/coreutils_test.go b/utils/coreutils_test.go index 88d82af0e..0e3ae2504 100644 --- a/utils/coreutils_test.go +++ b/utils/coreutils_test.go @@ -331,7 +331,7 @@ func TestParseTimeDetectLayout(t *testing.T) { } if nowTm, err := ParseTimeDetectLayout(META_NOW, ""); err != nil { t.Error(err) - } else if time.Now().Sub(nowTm) > time.Duration(10)*time.Millisecond { + } else if time.Now().Sub(nowTm) > 10*time.Millisecond { t.Errorf("Unexpected time parsed: %v", nowTm) } eamonTmStr := "31/05/2015 14:46:00" @@ -359,8 +359,8 @@ func TestParseTimeDetectLayout(t *testing.T) { t.Errorf("Expecting: %v, received: %v", expectedTime, astTMS) } nowTimeStr := "+24h" - start := time.Now().Add(time.Duration(23*time.Hour + 59*time.Minute + 58*time.Second)) - end := start.Add(time.Duration(2 * time.Second)) + start := time.Now().Add(23*time.Hour + 59*time.Minute + 58*time.Second) + end := start.Add(2 * time.Second) parseNowTimeStr, err := ParseTimeDetectLayout(nowTimeStr, "") if err != nil { t.Error(err) @@ -497,17 +497,17 @@ func TestParseTimeDetectLayout(t *testing.T) { func TestRoundDuration(t *testing.T) { minute := time.Minute - result := RoundDuration(minute, 0*time.Second) + result := RoundDuration(minute, 0) expected := 0 * time.Second if result != expected { t.Errorf("Error rounding to minute1: expected %v was %v", expected, result) } - result = RoundDuration(time.Second, 1*time.Second+500*time.Millisecond) + result = RoundDuration(time.Second, time.Second+500*time.Millisecond) expected = 2 * time.Second if result != expected { t.Errorf("Error rounding to minute1: expected %v was %v", expected, result) } - result = RoundDuration(minute, 1*time.Second) + result = RoundDuration(minute, time.Second) expected = minute if result != expected { t.Errorf("Error rounding to minute2: expected %v was %v", expected, result) @@ -535,32 +535,32 @@ func TestRoundDuration(t *testing.T) { } func TestRoundStatDuration(t *testing.T) { - result := RoundStatDuration(time.Duration(1*time.Second+14565876*time.Nanosecond), 5) - expected := time.Duration(1*time.Second + 14570000*time.Nanosecond) + result := RoundStatDuration(time.Second+14565876*time.Nanosecond, 5) + expected := time.Second + 14570000*time.Nanosecond if result != expected { t.Errorf("Expected %+v, received %+v", expected, result) } - result = RoundStatDuration(time.Duration(1*time.Second+14565876*time.Nanosecond), 1) - expected = time.Duration(1 * time.Second) + result = RoundStatDuration(time.Second+14565876*time.Nanosecond, 1) + expected = time.Second if result != expected { t.Errorf("Expected %+v, received %+v", expected, result) } - result = RoundStatDuration(time.Duration(1*time.Second+14565876*time.Nanosecond), 9) - expected = time.Duration(1*time.Second + 14565876*time.Nanosecond) + result = RoundStatDuration(time.Second+14565876*time.Nanosecond, 9) + expected = time.Second + 14565876*time.Nanosecond if result != expected { t.Errorf("Expected %+v, received %+v", expected, result) } - result = RoundStatDuration(time.Duration(24*time.Second+14565876*time.Nanosecond), -1) - expected = time.Duration(20 * time.Second) + result = RoundStatDuration(24*time.Second+14565876*time.Nanosecond, -1) + expected = 20 * time.Second if result != expected { t.Errorf("Expected %+v, received %+v", expected, result) } - result = RoundStatDuration(time.Duration(24*time.Second+14565876*time.Nanosecond), 0) - expected = time.Duration(24 * time.Second) + result = RoundStatDuration(24*time.Second+14565876*time.Nanosecond, 0) + expected = 24 * time.Second if result != expected { t.Errorf("Expected %+v, received %+v", expected, result) } @@ -620,7 +620,7 @@ func TestParseDurationWithSecs(t *testing.T) { t.Errorf("Expecting: 0s, received: %+v", rcv) } durStr := "2" - durExpected = time.Duration(2) * time.Second + durExpected = 2 * time.Second if parsed, err := ParseDurationWithSecs(durStr); err != nil { t.Error(err) } else if parsed != durExpected { @@ -633,21 +633,21 @@ func TestParseDurationWithSecs(t *testing.T) { t.Error("Parsed different than expected") } durStr = "2ms" - durExpected = time.Duration(2) * time.Millisecond + durExpected = 2 * time.Millisecond if parsed, err := ParseDurationWithSecs(durStr); err != nil { t.Error(err) } else if parsed != durExpected { t.Error("Parsed different than expected") } durStr = "0.002" - durExpected = time.Duration(2) * time.Millisecond + durExpected = 2 * time.Millisecond if parsed, err := ParseDurationWithSecs(durStr); err != nil { t.Error(err) } else if parsed != durExpected { t.Error("Parsed different than expected") } durStr = "1.002" - durExpected = time.Duration(1002) * time.Millisecond + durExpected = 1002 * time.Millisecond if parsed, err := ParseDurationWithSecs(durStr); err != nil { t.Error(err) } else if parsed != durExpected { @@ -688,7 +688,7 @@ func TestMinDuration(t *testing.T) { func TestParseZeroRatingSubject(t *testing.T) { subj := []string{"", "*zero1024", "*zero1s", "*zero5m", "*zero10h"} - dur := []time.Duration{time.Second, time.Duration(1024), + dur := []time.Duration{time.Second, 1024, time.Second, 5 * time.Minute, 10 * time.Hour} dfltRatingSubject := map[string]string{ ANY: "*zero1ns", @@ -1154,7 +1154,7 @@ func TestTimePointer(t *testing.T) { } func TestDurationPointer(t *testing.T) { - duration := time.Duration(10) + duration := 10 * time.Nanosecond result := DurationPointer(duration) expected := &duration if *expected != *result { @@ -1402,9 +1402,9 @@ func TestGetUrlRawArguments(t *testing.T) { func TestWarnExecTime(t *testing.T) { //without Log - WarnExecTime(time.Now(), "MyTestFunc", time.Duration(1*time.Second)) + WarnExecTime(time.Now(), "MyTestFunc", time.Second) //With Log - WarnExecTime(time.Now(), "MyTestFunc", time.Duration(1*time.Nanosecond)) + WarnExecTime(time.Now(), "MyTestFunc", time.Nanosecond) } func TestCastRPCErr(t *testing.T) { diff --git a/utils/dataconverter_test.go b/utils/dataconverter_test.go index 57fa48731..b4be6230e 100644 --- a/utils/dataconverter_test.go +++ b/utils/dataconverter_test.go @@ -355,13 +355,13 @@ func TestDivideConverterConvert(t *testing.T) { func TestNewDurationConverter(t *testing.T) { nS := &DurationConverter{} - eOut := time.Duration(0 * time.Second) + eOut := time.Duration(0) if rcv, err := nS.Convert(EmptyString); err != nil { t.Error(err) } else if !reflect.DeepEqual(eOut, rcv) { t.Errorf("Expected %+v received: %+v", eOut, rcv) } - eOut = time.Duration(7 * time.Nanosecond) + eOut = 7 * time.Nanosecond if rcv, err := nS.Convert(7); err != nil { t.Error(err) } else if !reflect.DeepEqual(eOut, rcv) { @@ -374,7 +374,7 @@ func TestConvertFloatToSeconds(t *testing.T) { if err != nil { t.Error(err.Error()) } - a, err := b.Convert(time.Duration(10*time.Second + 300*time.Millisecond)) + a, err := b.Convert(10*time.Second + 300*time.Millisecond) if err != nil { t.Error(err.Error()) } @@ -390,7 +390,7 @@ func TestConvertDurNanoseconds(t *testing.T) { t.Error(err.Error()) } expVal := int64(102) - if i, err := d.Convert(time.Duration(102)); err != nil { + if i, err := d.Convert(102); err != nil { t.Error(err.Error()) } else if expVal != i { t.Errorf("expecting: %d, received: %d", expVal, i) @@ -477,7 +477,7 @@ func TestRoundConverterTime(t *testing.T) { if !reflect.DeepEqual(b, expData) { t.Errorf("Expected %+v received: %+v", expData, b) } - val, err := b.Convert(time.Duration(123 * time.Nanosecond)) + val, err := b.Convert(123 * time.Nanosecond) if err != nil { t.Error(err.Error()) } @@ -496,7 +496,7 @@ func TestMultiplyConverter(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", eMpl, m) } expOut := 2048.0 - if out, err := m.Convert(time.Duration(2)); err != nil { + if out, err := m.Convert(2); err != nil { t.Error(err) } else if !reflect.DeepEqual(expOut, out) { t.Errorf("expecting: %+v, received: %+v", expOut, out) @@ -518,7 +518,7 @@ func TestDivideConverter(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", eDvd, d) } expOut := 2.0 - if out, err := d.Convert(time.Duration(2048)); err != nil { + if out, err := d.Convert(2048); err != nil { t.Error(err) } else if !reflect.DeepEqual(expOut, out) { t.Errorf("expecting: %+v, received: %+v", expOut, out) @@ -539,7 +539,7 @@ func TestDurationConverter(t *testing.T) { if err != nil { t.Error(err.Error()) } - expVal := time.Duration(10 * time.Second) + expVal := 10 * time.Second if i, err := d.Convert(10000000000.0); err != nil { t.Error(err.Error()) } else if expVal != i { @@ -550,7 +550,7 @@ func TestDurationConverter(t *testing.T) { } else if expVal != i { t.Errorf("expecting: %d, received: %d", expVal, i) } - if i, err := d.Convert(time.Duration(10 * time.Second)); err != nil { + if i, err := d.Convert(10 * time.Second); err != nil { t.Error(err.Error()) } else if expVal != i { t.Errorf("expecting: %d, received: %d", expVal, i) diff --git a/utils/reflect_test.go b/utils/reflect_test.go index d52e2c639..b89f42859 100644 --- a/utils/reflect_test.go +++ b/utils/reflect_test.go @@ -184,32 +184,32 @@ func TestGreaterThan(t *testing.T) { } else if !gte { t.Error("should be greater than") } - if gte, err := GreaterThan(time.Duration(2*time.Second), - time.Duration(1*time.Second), false); err != nil { + if gte, err := GreaterThan(2*time.Second, + time.Second, false); err != nil { t.Error(err) } else if !gte { t.Error("should be greater than") } - if gte, err := GreaterThan(time.Duration(2*time.Second), + if gte, err := GreaterThan(2*time.Second, 20, false); err != nil { t.Error(err) } else if !gte { t.Error("should be greater than") } - if gte, err := GreaterThan(time.Duration(2*time.Second), - float64(1*time.Second), false); err != nil { + if gte, err := GreaterThan(2*time.Second, + float64(time.Second), false); err != nil { t.Error(err) } else if !gte { t.Error("should be greater than") } - if gte, err := GreaterThan(time.Duration(1*time.Second), - time.Duration(2*time.Second), false); err != nil { + if gte, err := GreaterThan(time.Second, + 2*time.Second, false); err != nil { t.Error(err) } else if gte { t.Error("should be less than") } - if gte, err := GreaterThan(time.Duration(2*time.Second), - time.Duration(1*time.Second), false); err != nil { + if gte, err := GreaterThan(2*time.Second, + time.Second, false); err != nil { t.Error(err) } else if !gte { t.Error("should be greater than") @@ -243,7 +243,7 @@ func TestStringToInterface(t *testing.T) { if res := StringToInterface("1.2"); res != 1.2 { t.Error("not parsing float64") } - if res := StringToInterface("45s"); res != time.Duration(45*time.Second) { + if res := StringToInterface("45s"); res != 45*time.Second { t.Error("not parsing time.Duration") } res := StringToInterface("+24h") @@ -271,7 +271,7 @@ func TestIfaceAsString(t *testing.T) { if rply := IfaceAsString(val); rply != "true" { t.Errorf("Expected true ,received %+v", rply) } - if rply := IfaceAsString(time.Duration(1 * time.Second)); rply != "1s" { + if rply := IfaceAsString(time.Second); rply != "1s" { t.Errorf("Expected 1s ,received %+v", rply) } if rply := IfaceAsString(nil); rply != "" { @@ -312,8 +312,8 @@ func TestIfaceAsTime(t *testing.T) { } func TestIfaceAsDuration(t *testing.T) { - eItm := time.Duration(time.Second) - if itmConvert, err := IfaceAsDuration(interface{}(time.Duration(time.Second))); err != nil { + eItm := time.Second + if itmConvert, err := IfaceAsDuration(interface{}(time.Second)); err != nil { t.Error(err) } else if eItm != itmConvert { t.Errorf("received: %+v", itmConvert) @@ -351,7 +351,7 @@ func TestIfaceAsFloat64(t *testing.T) { } else if itmConvert != eFloat { t.Errorf("received: %+v", itmConvert) } - val = interface{}(time.Duration(6)) + val = interface{}(6) if itmConvert, err := IfaceAsFloat64(val); err != nil { t.Error(err) } else if itmConvert != eFloat { @@ -383,7 +383,7 @@ func TestIfaceAsInt64(t *testing.T) { } else if itmConvert != eInt { t.Errorf("received: %+v", itmConvert) } - val = interface{}(time.Duration(3)) + val = interface{}(3) if itmConvert, err := IfaceAsInt64(val); err != nil { t.Error(err) } else if itmConvert != eInt { @@ -415,7 +415,7 @@ func TestIfaceAsTInt64(t *testing.T) { } else if itmConvert != eInt { t.Errorf("received: %+v", itmConvert) } - val = interface{}(time.Duration(3)) + val = interface{}(3) if itmConvert, err := IfaceAsTInt64(val); err != nil { t.Error(err) } else if itmConvert != eInt { @@ -522,16 +522,16 @@ func TestSum(t *testing.T) { } else if sum != 17.069999999999997 { t.Errorf("Expecting: 17.069999999999997, received: %+v", sum) } - if sum, err := Sum(2*time.Second, 1*time.Second, 2*time.Second, + if sum, err := Sum(2*time.Second, time.Second, 2*time.Second, 5*time.Second, 4*time.Millisecond); err != nil { t.Error(err) } else if sum != 10*time.Second+4*time.Millisecond { t.Errorf("Expecting: 10.004s, received: %+v", sum) } - if sum, err := Sum(time.Duration(2*time.Second), - time.Duration(10*time.Millisecond)); err != nil { + if sum, err := Sum(2*time.Second, + 10*time.Millisecond); err != nil { t.Error(err) - } else if sum != time.Duration(2*time.Second+10*time.Millisecond) { + } else if sum != 2*time.Second+10*time.Millisecond { t.Errorf("Expecting: 2s10ms, received: %+v", sum) } } @@ -615,28 +615,28 @@ func TestDifference(t *testing.T) { } else if diff != 3.0 { t.Errorf("Expecting: 3.0, received: %+v", diff) } - if diff, err := Difference(10*time.Second, 1*time.Second, 2*time.Second, + if diff, err := Difference(10*time.Second, time.Second, 2*time.Second, 4*time.Millisecond); err != nil { t.Error(err) - } else if diff != time.Duration(6*time.Second+996*time.Millisecond) { + } else if diff != 6*time.Second+996*time.Millisecond { t.Errorf("Expecting: 6.996ms, received: %+v", diff) } - if diff, err := Difference(time.Duration(2*time.Second), - time.Duration(10*time.Millisecond)); err != nil { + if diff, err := Difference(2*time.Second, + 10*time.Millisecond); err != nil { t.Error(err) - } else if diff != time.Duration(1*time.Second+990*time.Millisecond) { + } else if diff != time.Second+990*time.Millisecond { t.Errorf("Expecting: 1.99s, received: %+v", diff) } if diff, err := Difference(time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC), - time.Duration(10*time.Second)); err != nil { + 10*time.Second); err != nil { t.Error(err) } else if diff != time.Date(2009, 11, 10, 22, 59, 50, 0, time.UTC) { t.Errorf("Expecting: %+v, received: %+v", time.Date(2009, 11, 10, 22, 59, 50, 0, time.UTC), diff) } if diff, err := Difference(time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC), - time.Duration(10*time.Second), 10000000000); err != nil { + 10*time.Second, 10000000000); err != nil { t.Error(err) } else if diff != time.Date(2009, 11, 10, 22, 59, 40, 0, time.UTC) { t.Errorf("Expecting: %+v, received: %+v", time.Date(2009, 11, 10, 22, 59, 40, 0, time.UTC), diff) @@ -730,8 +730,8 @@ func TestEqualTo(t *testing.T) { } else if !gte { t.Error("should be equal") } - if gte, err := EqualTo(time.Duration(2*time.Second), - time.Duration(2*time.Second)); err != nil { + if gte, err := EqualTo(2*time.Second, + 2*time.Second); err != nil { t.Error(err) } else if !gte { t.Error("should be equal") diff --git a/utils/server.go b/utils/server.go index c07267352..fe7c83922 100644 --- a/utils/server.go +++ b/utils/server.go @@ -172,7 +172,7 @@ func (s *Server) ServeJSON(addr string, exitChan chan bool) { if err != nil { Logger.Err(fmt.Sprintf(" JSON accept error: <%s>", err.Error())) now := time.Now() - if now.Sub(lastErrorTime) > time.Duration(5*time.Second) { + if now.Sub(lastErrorTime) > 5*time.Second { errCnt = 0 // reset error count if last error was more than 5 seconds ago } lastErrorTime = time.Now() @@ -208,7 +208,7 @@ func (s *Server) ServeGOB(addr string, exitChan chan bool) { if err != nil { Logger.Err(fmt.Sprintf(" GOB accept error: <%s>", err.Error())) now := time.Now() - if now.Sub(lastErrorTime) > time.Duration(5*time.Second) { + if now.Sub(lastErrorTime) > 5*time.Second { errCnt = 0 // reset error count if last error was more than 5 seconds ago } lastErrorTime = time.Now() @@ -463,7 +463,7 @@ func (s *Server) ServeGOBTLS(addr, serverCrt, serverKey, caCert string, if err != nil { Logger.Err(fmt.Sprintf(" TLS accept error: <%s>", err.Error())) now := time.Now() - if now.Sub(lastErrorTime) > time.Duration(5*time.Second) { + if now.Sub(lastErrorTime) > 5*time.Second { errCnt = 0 // reset error count if last error was more than 5 seconds ago } lastErrorTime = time.Now() @@ -504,7 +504,7 @@ func (s *Server) ServeJSONTLS(addr, serverCrt, serverKey, caCert string, if err != nil { Logger.Err(fmt.Sprintf(" TLS accept error: <%s>", err.Error())) now := time.Now() - if now.Sub(lastErrorTime) > time.Duration(5*time.Second) { + if now.Sub(lastErrorTime) > 5*time.Second { errCnt = 0 // reset error count if last error was more than 5 seconds ago } lastErrorTime = time.Now()