From 2d042d65bfa699eb83d9eb78537346c7f2552b2a Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 21 Apr 2014 19:12:38 +0300 Subject: [PATCH 1/3] ignore empty commands (enter enter) --- cmd/cgr-console/cgr-console.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/cgr-console/cgr-console.go b/cmd/cgr-console/cgr-console.go index ed4d40aa4..17c1bdfe0 100644 --- a/cmd/cgr-console/cgr-console.go +++ b/cmd/cgr-console/cgr-console.go @@ -44,6 +44,9 @@ var ( ) func executeCommand(command string) { + if strings.TrimSpace(command) == "" { + return + } if strings.TrimSpace(command) == "help" { commands := console.GetCommands() fmt.Println("Commands:") From 251d504d40ed9111f7ef62e116e810f62c050966 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 23 Apr 2014 13:23:58 +0300 Subject: [PATCH 2/3] fix for callcost out of bounds merge (thanks DigiDaz) --- engine/callcost.go | 2 +- engine/callcost_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/engine/callcost.go b/engine/callcost.go index dff4be5c5..3dd1a4aab 100644 --- a/engine/callcost.go +++ b/engine/callcost.go @@ -46,7 +46,7 @@ type CallCost struct { // Merges the received timespan if they are similar (same activation period, same interval, same minute info. func (cc *CallCost) Merge(other *CallCost) { - if len(cc.Timespans)-1 < 0 { + if len(cc.Timespans)-1 < 0 || len(other.Timespans) == 0 { return } ts := cc.Timespans[len(cc.Timespans)-1] diff --git a/engine/callcost_test.go b/engine/callcost_test.go index 0b9919d0e..5b8fa78e2 100644 --- a/engine/callcost_test.go +++ b/engine/callcost_test.go @@ -125,6 +125,18 @@ func TestMultipleInputRightMerge(t *testing.T) { } } +func TestCallCostMergeEmpty(t *testing.T) { + t1 := time.Date(2012, time.February, 2, 17, 58, 0, 0, time.UTC) + t2 := time.Date(2012, time.February, 2, 17, 59, 0, 0, time.UTC) + cd := &CallDescriptor{Direction: OUTBOUND, TOR: "0", Tenant: "vdf", Subject: "rif", Destination: "0256", TimeStart: t1, TimeEnd: t2} + cc1, _ := cd.GetCost() + cc2 := &CallCost{} + cc1.Merge(cc2) + if len(cc1.Timespans) != 1 { + t.Error("Error mergin empty call cost: ", len(cc1.Timespans)) + } +} + func TestCallCostGetDurationZero(t *testing.T) { cc := &CallCost{} if cc.GetDuration().Seconds() != 0 { From b4dbb1ca9e27e68f090f61beaf6aa7330193a14d Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 23 Apr 2014 13:32:18 +0300 Subject: [PATCH 3/3] more time for the scheduler --- general_tests/ddazmbl1_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/general_tests/ddazmbl1_test.go b/general_tests/ddazmbl1_test.go index b9fb9dd1f..c74a2b02e 100644 --- a/general_tests/ddazmbl1_test.go +++ b/general_tests/ddazmbl1_test.go @@ -120,7 +120,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` func TestExecuteActions(t *testing.T) { scheduler.NewScheduler().LoadActionTimings(acntDb) - time.Sleep(time.Duration(100) * time.Microsecond) // Give time to scheduler to topup the account + time.Sleep(time.Millisecond) // Give time to scheduler to topup the account if acnt, err := acntDb.GetAccount("*out:cgrates.org:12345"); err != nil { t.Error(err) } else if len(acnt.BalanceMap) != 2 {