mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Test OptAsString func in utils/cgrevent.go
This commit is contained in:
committed by
Dan Christian Bogos
parent
ee642fcc1a
commit
cb96219bcd
@@ -19,6 +19,7 @@ package utils
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -435,3 +436,37 @@ func TestCGREventWithOptsCache(t *testing.T) {
|
||||
}
|
||||
event.CacheClear()
|
||||
}
|
||||
|
||||
func TestCGREventOptAsStringEmpty(t *testing.T) {
|
||||
ev := &CGREvent{}
|
||||
|
||||
expstr := ""
|
||||
experr := ErrNotFound
|
||||
received, err := ev.OptAsString("testString")
|
||||
|
||||
if !reflect.DeepEqual(received, expstr) {
|
||||
t.Errorf("\nReceived: %q, \nExpected: %q", received, expstr)
|
||||
}
|
||||
if err == nil || err != experr {
|
||||
t.Errorf("\nReceived: %q, \nExpected: %q", err, experr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCGREventOptAsString(t *testing.T) {
|
||||
ev := &CGREvent{
|
||||
Opts: map[string]interface{}{
|
||||
"testKey": 13,
|
||||
},
|
||||
}
|
||||
|
||||
received, err := ev.OptAsString("testKey")
|
||||
if err != nil {
|
||||
t.Errorf("\nReceived: <%+v>, \nExpected: <%+v>", err, nil)
|
||||
}
|
||||
expected := strconv.Itoa(13)
|
||||
|
||||
if received != expected {
|
||||
t.Errorf("\nReceived: %q, \nExpected: %q", received, expected)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user