mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
simple tests in place
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user