This commit is contained in:
DanB
2014-04-25 09:32:28 +02:00
4 changed files with 17 additions and 2 deletions

View File

@@ -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:")

View File

@@ -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]

View File

@@ -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 {

View File

@@ -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 {