simple tests in place

This commit is contained in:
Radu Ioan Fericean
2012-01-30 20:10:57 +02:00
parent e83bf2514b
commit 2def2c1fbf
3 changed files with 30 additions and 11 deletions

View File

@@ -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
}
/*

View File

@@ -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
}

View File

@@ -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)
}
}