mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
more tests more corrections
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
//"log"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -61,8 +62,10 @@ func (ap *ActivationPeriod) restore(input string) {
|
||||
i.Month = time.Month(month)
|
||||
i.MonthDay, _ = strconv.Atoi(ise[1])
|
||||
for _, d := range strings.Split(ise[2], ",") {
|
||||
wd, _ := strconv.Atoi(d)
|
||||
i.WeekDays = append(i.WeekDays, time.Weekday(wd))
|
||||
if d != ""{
|
||||
wd, _ := strconv.Atoi(d)
|
||||
i.WeekDays = append(i.WeekDays, time.Weekday(wd))
|
||||
}
|
||||
}
|
||||
i.StartTime = ise[3]
|
||||
i.EndTime = ise[4]
|
||||
|
||||
@@ -118,7 +118,7 @@ func (cd *CallDescriptor) GetCost(sg StorageGetter) (result *CallCost, err error
|
||||
destPrefix, err := cd.RestoreFromStorage(sg)
|
||||
|
||||
timespans := cd.splitInTimeSpans()
|
||||
|
||||
|
||||
cost := 0.0
|
||||
for _, ts := range timespans {
|
||||
cost += ts.GetCost()
|
||||
|
||||
@@ -126,6 +126,20 @@ func TestLessThanAMinute(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUniquePrice(t *testing.T) {
|
||||
getter, _ := NewRedisStorage("tcp:127.0.0.1:6379", 10)
|
||||
defer getter.Close()
|
||||
|
||||
t1 := time.Date(2012, time.February, 8, 22, 50, 0, 0, time.UTC)
|
||||
t2 := time.Date(2012, time.February, 8, 23, 50, 21, 0, time.UTC)
|
||||
cd := &CallDescriptor{CstmId: "vdf", Subject: "rif", DestinationPrefix: "0723045326", TimeStart: t1, TimeEnd: t2}
|
||||
result, _ := cd.GetCost(getter)
|
||||
expected := &CallCost{CstmId: "vdf", Subject: "rif", DestinationPrefix: "0723", Cost: 60.35, ConnectFee: 0}
|
||||
if *result != *expected {
|
||||
t.Errorf("Expected %v was %v", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************** BENCHMARKS ***************************************/
|
||||
func BenchmarkRedisGetting(b *testing.B) {
|
||||
b.StopTimer()
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
//"log"
|
||||
)
|
||||
|
||||
/*
|
||||
|
||||
Binary file not shown.
@@ -22,5 +22,12 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{"TOR": 0,"CstmId":"vdf","Subject":"rif","DestinationPrefix":"0723", "ActivationPeriods": [
|
||||
{"ActivationTime": "2012-01-01T00:00:00Z", "Intervals": [
|
||||
{"BillingUnit":60,"ConnectFee":0,"Month":0,"MonthDay":0,"Ponder":0,"Price":1,"StartTime":"","EndTime":""}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user