TestSMCosts

This commit is contained in:
DanB
2015-12-28 10:31:16 +01:00
parent 467c194b7f
commit 98473b930a
2 changed files with 33 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ import (
"flag"
"fmt"
"path"
//"reflect"
"reflect"
"testing"
"time"
@@ -51,6 +51,9 @@ func TestITCDRsMySQL(t *testing.T) {
if err := testSetCDR(mysqlDb); err != nil {
t.Error(err)
}
if err := testSMCosts(mysqlDb); err != nil {
t.Error(err)
}
}
func TestITCDRsPSQL(t *testing.T) {
@@ -72,6 +75,9 @@ func TestITCDRsPSQL(t *testing.T) {
if err := testSetCDR(psqlDb); err != nil {
t.Error(err)
}
if err := testSMCosts(psqlDb); err != nil {
t.Error(err)
}
}
// helper function to populate CDRs and check if they were stored in storDb
@@ -175,3 +181,28 @@ func testSetCDR(cdrStorage CdrStorage) error {
}
return nil
}
func testSMCosts(cdrStorage CdrStorage) error {
cc := &CallCost{
Direction: utils.OUT,
Destination: "+4986517174963",
Timespans: []*TimeSpan{
&TimeSpan{
TimeStart: time.Date(2015, 12, 28, 8, 53, 0, 0, time.UTC),
TimeEnd: time.Date(2015, 12, 28, 8, 54, 40, 0, time.UTC),
DurationIndex: 0,
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
TOR: utils.VOICE,
}
if err := cdrStorage.LogCallCost("164b0422fdc6a5117031b427439482c6a4f90e41", utils.META_DEFAULT, utils.UNIT_TEST, cc); err != nil {
return err
}
if rcvCC, err := cdrStorage.GetCallCostLog("164b0422fdc6a5117031b427439482c6a4f90e41", utils.META_DEFAULT); err != nil {
return err
} else if !reflect.DeepEqual(cc, rcvCC) {
return fmt.Errorf("Expecting: %+v, received: %+v", cc, rcvCC)
}
return nil
}

View File

@@ -569,7 +569,7 @@ func (self *SQLStorage) SetTpAccountActions(aas []TpAccountAction) error {
return nil
}
func (self *SQLStorage) LogCallCost(cgrid, runid, source string, cc *CallCost) (err error) { //
func (self *SQLStorage) LogCallCost(cgrid, runid, source string, cc *CallCost) error {
if cc == nil {
return nil
}