mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 06:09:53 +05:00
Updated tests in session
This commit is contained in:
committed by
Dan Christian Bogos
parent
a884584f67
commit
5c3816f60c
@@ -154,6 +154,9 @@ func (me MapEvent) GetTimeIgnoreErrors(fldName string, tmz string) (t time.Time)
|
||||
|
||||
// Clone returns the cloned map
|
||||
func (me MapEvent) Clone() (mp MapEvent) {
|
||||
if me == nil {
|
||||
return nil
|
||||
}
|
||||
mp = make(MapEvent, len(me))
|
||||
for k, v := range me {
|
||||
mp[k] = v
|
||||
|
||||
@@ -27,6 +27,74 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestSessionIDCGRID(t *testing.T) {
|
||||
//empty check
|
||||
sessionID := new(SessionID)
|
||||
rcv := sessionID.CGRID()
|
||||
eOut := "da39a3ee5e6b4b0d3255bfef95601890afd80709"
|
||||
if !reflect.DeepEqual(eOut, rcv) {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eOut), utils.ToJSON(rcv))
|
||||
}
|
||||
//normal check
|
||||
sessionID.OriginHost = "testhost"
|
||||
sessionID.OriginID = "testid"
|
||||
rcv = sessionID.CGRID()
|
||||
eOut = "2aaff7e3e832de08b0604a79a18ccc6bba823360"
|
||||
if !reflect.DeepEqual(eOut, rcv) {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eOut), utils.ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionCgrID(t *testing.T) {
|
||||
//empty check
|
||||
session := new(Session)
|
||||
rcv := session.cgrID()
|
||||
eOut := ""
|
||||
if !reflect.DeepEqual(eOut, rcv) {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eOut), utils.ToJSON(rcv))
|
||||
}
|
||||
//normal check
|
||||
session.CGRID = "testID"
|
||||
eOut = "testID"
|
||||
rcv = session.cgrID()
|
||||
if !reflect.DeepEqual(eOut, rcv) && session.CGRID == "testID" {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eOut), utils.ToJSON(rcv))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestSessionClone(t *testing.T) {
|
||||
//empty check
|
||||
session := new(Session)
|
||||
rcv := session.Clone()
|
||||
eOut := new(Session)
|
||||
if !reflect.DeepEqual(eOut, rcv) {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eOut), utils.ToJSON(rcv))
|
||||
}
|
||||
//normal check
|
||||
session = &Session{
|
||||
CGRID: "CGRID",
|
||||
Tenant: "cgrates.org",
|
||||
ResourceID: "resourceID",
|
||||
ClientConnID: "ClientConnID",
|
||||
EventStart: engine.NewMapEvent(nil),
|
||||
DebitInterval: time.Duration(18),
|
||||
}
|
||||
eOut = &Session{
|
||||
CGRID: "CGRID",
|
||||
Tenant: "cgrates.org",
|
||||
ResourceID: "resourceID",
|
||||
ClientConnID: "ClientConnID",
|
||||
EventStart: engine.NewMapEvent(nil),
|
||||
DebitInterval: time.Duration(18),
|
||||
}
|
||||
rcv = session.Clone()
|
||||
if !reflect.DeepEqual(eOut, rcv) && session.CGRID == "testID" {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eOut), utils.ToJSON(rcv))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Test1 ExtraDuration 0 and LastUsage < initial
|
||||
|
||||
//Test1 ExtraDuration 0 and LastUsage < initial
|
||||
|
||||
Reference in New Issue
Block a user