From 29e3bd137bf000f09d68f41be132a451ca051110 Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 25 Mar 2014 13:30:39 +0100 Subject: [PATCH] Fixup build, removed removeFromDb parameter in cdr_export console command --- apier/tutfsjson_local_test.go | 6 +++--- console/export_cdrs.go | 11 ++++------- engine/storage_sql_local_test.go | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apier/tutfsjson_local_test.go b/apier/tutfsjson_local_test.go index b2e45a3be..264ad5937 100644 --- a/apier/tutfsjson_local_test.go +++ b/apier/tutfsjson_local_test.go @@ -413,7 +413,7 @@ func TestMaxDebit1001(t *testing.T) { for _, blnc := range blncLst { if blnc.SharedGroup == "SHARED_A" && blnc.Value != 5 { t.Errorf("Unexpected value for shared balance: %f", blnc.Value) - } else if len(blnc.SharedGroup) == 0 && blnc.Value != 4.7 { + } else if len(blnc.SharedGroup) == 0 && blnc.Value != 4.4 { t.Errorf("Unexpected value for general balance: %f", blnc.Value) } } @@ -448,9 +448,9 @@ func TestMaxDebit1007(t *testing.T) { } blncLst := acnt.BalanceMap["*monetary*out"] for _, blnc := range blncLst { - if blnc.SharedGroup == "SHARED_A" && blnc.Value != 4.7 { + if blnc.SharedGroup == "SHARED_A" && blnc.Value != 4 { t.Errorf("Unexpected value for shared balance: %f", blnc.Value) - } else if len(blnc.SharedGroup) == 0 && blnc.Value != 4.7 { + } else if len(blnc.SharedGroup) == 0 && blnc.Value != 4.4 { t.Errorf("Unexpected value for general balance: %f", blnc.Value) } } diff --git a/console/export_cdrs.go b/console/export_cdrs.go index ae5e285a8..65a0e2d1d 100644 --- a/console/export_cdrs.go +++ b/console/export_cdrs.go @@ -37,13 +37,13 @@ type CmdExportCdrs struct { // name should be exec's name func (self *CmdExportCdrs) Usage(name string) string { - return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] export_cdrs [ [ [remove_from_db]]]") + return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] export_cdrs [ [ ]]") } // set param defaults func (self *CmdExportCdrs) defaults() error { self.rpcMethod = "ApierV1.ExportCdrsToFile" - self.rpcParams = &utils.AttrExpFileCdrs{CdrFormat:"csv"} + self.rpcParams = &utils.AttrExpFileCdrs{CdrFormat: "csv"} return nil } @@ -60,20 +60,17 @@ func (self *CmdExportCdrs) FromArgs(args []string) error { switch len(args) { case 4: timeStart = args[3] - + case 5: timeStart = args[3] timeEnd = args[4] case 6: timeStart = args[3] timeEnd = args[4] - if args[5] == "remove_from_db" { - self.rpcParams.RemoveFromDb = true - } } if timeStart == "*one_month" { now := time.Now() - self.rpcParams.TimeStart = now.AddDate(0,-1,0).String() + self.rpcParams.TimeStart = now.AddDate(0, -1, 0).String() self.rpcParams.TimeEnd = now.String() } else { self.rpcParams.TimeStart = timeStart diff --git a/engine/storage_sql_local_test.go b/engine/storage_sql_local_test.go index 88c66aabf..687c66ab2 100644 --- a/engine/storage_sql_local_test.go +++ b/engine/storage_sql_local_test.go @@ -218,6 +218,20 @@ func TestGetStoredCdrs(t *testing.T) { } else if len(storedCdrs) != 8 { t.Error("Unexpected number of StoredCdrs returned: ", storedCdrs) } + // Filter on cgrids + if storedCdrs, err := mysql.GetStoredCdrs([]string{utils.FSCgrId("bbb1"), utils.FSCgrId("bbb2")}, + "", "", "", "", "", "", "", "", "", "", timeStart, timeEnd, false, false); err != nil { + t.Error(err.Error()) + } else if len(storedCdrs) != 2 { + t.Error("Unexpected number of StoredCdrs returned: ", storedCdrs) + } + // Filter on cgrids plus reqType + if storedCdrs, err := mysql.GetStoredCdrs([]string{utils.FSCgrId("bbb1"), utils.FSCgrId("bbb2")}, + "", "", "", "prepaid", "", "", "", "", "", "", timeStart, timeEnd, false, false); err != nil { + t.Error(err.Error()) + } else if len(storedCdrs) != 1 { + t.Error("Unexpected number of StoredCdrs returned: ", storedCdrs) + } // Filter on runId if storedCdrs, err := mysql.GetStoredCdrs(nil, utils.DEFAULT_RUNID, "", "", "", "", "", "", "", "", "", timeStart, timeEnd, false, false); err != nil { t.Error(err.Error())