better tests for max session time

This commit is contained in:
Radu Ioan Fericean
2015-07-27 21:16:39 +03:00
parent f3257b5dba
commit 4203a49ac8
2 changed files with 6 additions and 5 deletions

View File

@@ -531,6 +531,7 @@ func (origCD *CallDescriptor) getMaxSessionDuration(origAcc *Account) (time.Dura
//
cc, err := cd.debit(account, true, false)
//Logger.Debug("CC: " + utils.ToJSON(cc))
//log.Print("CC: ", utils.ToIJSON(cc))
//Logger.Debug(fmt.Sprintf("ERR: %v", err))
if err != nil {
return 0, err

View File

@@ -860,8 +860,8 @@ func TestMaxSesionTimeEmptyBalanceAndNoCost(t *testing.T) {
func TestMaxSesionTimeLong(t *testing.T) {
cd := &CallDescriptor{
TimeStart: time.Date(2015, 07, 26, 13, 37, 0, 0, time.UTC),
TimeEnd: time.Date(2015, 07, 26, 16, 37, 0, 0, time.UTC),
TimeStart: time.Date(2015, 07, 24, 13, 37, 0, 0, time.UTC),
TimeEnd: time.Date(2015, 07, 24, 15, 37, 0, 0, time.UTC),
Direction: "*out",
Category: "call",
Tenant: "cgrates.org",
@@ -877,8 +877,8 @@ func TestMaxSesionTimeLong(t *testing.T) {
func TestMaxSesionTimeLongerThanMoney(t *testing.T) {
cd := &CallDescriptor{
TimeStart: time.Date(2015, 07, 26, 13, 37, 0, 0, time.UTC),
TimeEnd: time.Date(2015, 07, 26, 19, 37, 0, 0, time.UTC),
TimeStart: time.Date(2015, 07, 24, 13, 37, 0, 0, time.UTC),
TimeEnd: time.Date(2015, 07, 24, 16, 37, 0, 0, time.UTC),
Direction: "*out",
Category: "call",
Tenant: "cgrates.org",
@@ -887,7 +887,7 @@ func TestMaxSesionTimeLongerThanMoney(t *testing.T) {
}
acc, _ := accountingStorage.GetAccount("*out:cgrates.org:money")
allowedTime, err := cd.getMaxSessionDuration(acc)
expected, err := time.ParseDuration("5h33m20s")
expected, err := time.ParseDuration("2h46m40s")
if err != nil || allowedTime != expected {
t.Errorf("Expected: %v got %v", expected, allowedTime)
}