From 52b1358e9aaaa23636d4a48139e65860a619dd66 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Sun, 14 Apr 2013 15:13:04 +0300 Subject: [PATCH] put reference of the slices in array not slice ref value --- cache2go/.gitignore | 22 ++++++++++++++++++++++ mediator/mediator.go | 2 +- mediator/mediator_test.go | 19 +++++++++++++++---- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 cache2go/.gitignore diff --git a/cache2go/.gitignore b/cache2go/.gitignore new file mode 100644 index 000000000..00268614f --- /dev/null +++ b/cache2go/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe diff --git a/mediator/mediator.go b/mediator/mediator.go index eac011370..451b0c6a7 100644 --- a/mediator/mediator.go +++ b/mediator/mediator.go @@ -158,7 +158,7 @@ func (m *Mediator) parseCSV(cdrfn string) (err error) { w := bufio.NewWriter(fout) for record, ok := csvReader.Read(); ok == nil; record, ok = csvReader.Read() { - //t, _ := time.Parse("2012-05-21 17:48:20", record[5]) + //t, _ := time.Parse("2006-01-02 15:04:05", record[5]) var cc *rater.CallCost for runIdx, idxVal := range m.subjectIndexs { // Query costs for every run index given by subject if idxVal == -1 { // -1 as subject means use database to get previous set price diff --git a/mediator/mediator_test.go b/mediator/mediator_test.go index 45742ccd7..e217b6645 100644 --- a/mediator/mediator_test.go +++ b/mediator/mediator_test.go @@ -30,8 +30,8 @@ func TestIndexLoadEmpty(t *testing.T) { func TestIndexLengthSame(t *testing.T) { m := new(Mediator) - objs := []mediatorFieldIdxs{m.directionIndexs, m.torIndexs, m.tenantIndexs, m.subjectIndexs, - m.accountIndexs, m.destinationIndexs, m.timeStartIndexs, m.durationIndexs, m.uuidIndexs} + objs := []*mediatorFieldIdxs{&m.directionIndexs, &m.torIndexs, &m.tenantIndexs, &m.subjectIndexs, + &m.accountIndexs, &m.destinationIndexs, &m.timeStartIndexs, &m.durationIndexs, &m.uuidIndexs} for _, o := range objs { o.Load("1,2,3") } @@ -42,8 +42,8 @@ func TestIndexLengthSame(t *testing.T) { func TestIndexLengthDifferent(t *testing.T) { m := new(Mediator) - objs := []mediatorFieldIdxs{m.directionIndexs, m.torIndexs, m.tenantIndexs, m.subjectIndexs, - m.accountIndexs, m.timeStartIndexs, m.durationIndexs, m.uuidIndexs} + objs := []*mediatorFieldIdxs{&m.directionIndexs, &m.torIndexs, &m.tenantIndexs, &m.subjectIndexs, + &m.accountIndexs, &m.timeStartIndexs, &m.durationIndexs, &m.uuidIndexs} for _, o := range objs { o.Load("1,2,3") } @@ -52,3 +52,14 @@ func TestIndexLengthDifferent(t *testing.T) { t.Error("Error checking length") } } + +func TestLoad(t *testing.T) { + m := new(Mediator) + objs := []*mediatorFieldIdxs{&m.directionIndexs} + for _, o := range objs { + o.Load("1,2,3") + } + if len(m.directionIndexs) != 3 { + t.Errorf("Expected %v was %v", 3, len(m.directionIndexs)) + } +}