From 2def2c1fbf3eebe3596e0c711475f89ce2d2428e Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 30 Jan 2012 20:10:57 +0200 Subject: [PATCH] simple tests in place --- cmd/rater/rater.go | 7 ++++--- timeslots/timeslots.go | 17 ++++++++++++----- timeslots/timeslots_test.go | 17 ++++++++++++++--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/cmd/rater/rater.go b/cmd/rater/rater.go index d14ca18c4..ee8f2b2ea 100644 --- a/cmd/rater/rater.go +++ b/cmd/rater/rater.go @@ -26,9 +26,10 @@ func NewStorage(nsg timeslots.StorageGetter) *Storage{ /* RPC method providing the rating information from the storage. */ -func (s *Storage) GetCost(in *timeslots.CallDescription, reply *string) (err error) { - *reply, err = timeslots.GetCost(in, s.sg) - return err +func (s *Storage) GetCost(in *timeslots.CallDescription, reply *CallCost) (error) { + r, e := timeslots.GetCost(in, s.sg) + *replay, err = r, e + return e } /* diff --git a/timeslots/timeslots.go b/timeslots/timeslots.go index 2f156a7e2..c7851a4f1 100644 --- a/timeslots/timeslots.go +++ b/timeslots/timeslots.go @@ -31,12 +31,19 @@ const ( ) type CallDescription struct { - tOR int - cstmId, subject, destination string - timeStart, timeEnd time.Time + TOR int + CstmId, Subject, Destination string + TimeStart, TimeEnd time.Time } -func GetCost(in *CallDescription, sg StorageGetter) (result string, err error) { - return "", nil +type CallCost struct { + TOR int + CstmId, Subjext, Prefix string + Cost, ConnectFee float32 +// ratesInfo *RatingProfile +} + +func GetCost(in *CallDescription, sg StorageGetter) (result *CallCost, err error) { + return &CallCost{TOR: 1, CstmId:"",Subjext:"",Prefix:"", Cost:1, ConnectFee:1}, nil } diff --git a/timeslots/timeslots_test.go b/timeslots/timeslots_test.go index 554b0cfa3..496cc2cbf 100644 --- a/timeslots/timeslots_test.go +++ b/timeslots/timeslots_test.go @@ -1,11 +1,22 @@ package timeslots -func TestSimple(*testing.T){ - +import ( + "testing" +) + +func TestSimple(t *testing.T){ + cc, err := GetCost(nil, nil) + if err != nil { + t.Error("Got error on getting cost") + } + expected:= &CallCost{TOR: 1, CstmId:"",Subjext:"",Prefix:"", Cost:1, ConnectFee:1} + if *cc != *expected { + t.Errorf("Expected %v got %v", expected, cc) + } } func BenchmarkSimple(b *testing.B) { for i := 0; i < b.N; i++ { - GetCost() + GetCost(nil, nil) } } \ No newline at end of file