mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-16 05:39:54 +05:00
Updated load tests for listencfg
This commit is contained in:
committed by
Dan Christian Bogos
parent
f59c6cde11
commit
4a5706bcc1
@@ -25,28 +25,15 @@ import (
|
||||
)
|
||||
|
||||
func TestListenCfgloadFromJsonCfg(t *testing.T) {
|
||||
var lstcfg, expected ListenCfg
|
||||
if err := lstcfg.loadFromJsonCfg(nil); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(lstcfg, expected) {
|
||||
t.Errorf("Expected: %+v ,recived: %+v", expected, lstcfg)
|
||||
jsonCfg := &ListenJsonCfg{
|
||||
Rpc_json: utils.StringPointer("127.0.0.1:2012"),
|
||||
Rpc_gob: utils.StringPointer("127.0.0.1:2013"),
|
||||
Http: utils.StringPointer("127.0.0.1:2080"),
|
||||
Rpc_json_tls: utils.StringPointer("127.0.0.1:2022"),
|
||||
Rpc_gob_tls: utils.StringPointer("127.0.0.1:2023"),
|
||||
Http_tls: utils.StringPointer("127.0.0.1:2280"),
|
||||
}
|
||||
if err := lstcfg.loadFromJsonCfg(new(ListenJsonCfg)); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(lstcfg, expected) {
|
||||
t.Errorf("Expected: %+v ,recived: %+v", expected, lstcfg)
|
||||
}
|
||||
cfgJSONStr := `{
|
||||
"listen": {
|
||||
"rpc_json": "127.0.0.1:2012", // RPC JSON listening address
|
||||
"rpc_gob": "127.0.0.1:2013", // RPC GOB listening address
|
||||
"http": "127.0.0.1:2080", // HTTP listening address
|
||||
"rpc_json_tls" : "127.0.0.1:2022", // RPC JSON TLS listening address
|
||||
"rpc_gob_tls": "127.0.0.1:2023", // RPC GOB TLS listening address
|
||||
"http_tls": "127.0.0.1:2280", // HTTP TLS listening address
|
||||
}
|
||||
}`
|
||||
expected = ListenCfg{
|
||||
expected := &ListenCfg{
|
||||
RPCJSONListen: "127.0.0.1:2012",
|
||||
RPCGOBListen: "127.0.0.1:2013",
|
||||
HTTPListen: "127.0.0.1:2080",
|
||||
@@ -54,14 +41,12 @@ func TestListenCfgloadFromJsonCfg(t *testing.T) {
|
||||
RPCGOBTLSListen: "127.0.0.1:2023",
|
||||
HTTPTLSListen: "127.0.0.1:2280",
|
||||
}
|
||||
if jsnCfg, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
|
||||
if jsnCfg, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
} else if jsnLstCfg, err := jsnCfg.ListenJsonCfg(); err != nil {
|
||||
} else if err = jsnCfg.listenCfg.loadFromJsonCfg(jsonCfg); err != nil {
|
||||
t.Error(err)
|
||||
} else if err = lstcfg.loadFromJsonCfg(jsnLstCfg); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expected, lstcfg) {
|
||||
t.Errorf("Expected: %+v , recived: %+v", expected, lstcfg)
|
||||
} else if !reflect.DeepEqual(expected, jsnCfg.listenCfg) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(jsnCfg.listenCfg))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user