mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Cover tests in Dispatchers
This commit is contained in:
committed by
Dan Christian Bogos
parent
8869de64ee
commit
a85b87cae7
@@ -122,3 +122,53 @@ func TestDispatcherDispatch(t *testing.T) {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDispatcherAuthorizeError(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
cfg.DispatcherSCfg().AttributeSConns = []string{"connID"}
|
||||
cfg.RPCConns()["connID"] = &config.RPCConn{
|
||||
Strategy: rpcclient.PoolFirst,
|
||||
PoolSize: 0,
|
||||
Conns: []*config.RemoteHost{
|
||||
{
|
||||
ID: "",
|
||||
Address: "error",
|
||||
Transport: "",
|
||||
Synchronous: false,
|
||||
TLS: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
connMng := engine.NewConnManager(cfg, nil)
|
||||
dsp := NewDispatcherService(nil, cfg, nil, connMng)
|
||||
err := dsp.authorize("", "cgrates.org", utils.APIMethods, nil)
|
||||
expected := "dial tcp: address error: missing port in address"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDispatcherAuthorizeError2(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
cfg.DispatcherSCfg().AttributeSConns = []string{utils.APIMethods}
|
||||
cfg.RPCConns()[utils.APIMethods] = &config.RPCConn{
|
||||
Strategy: rpcclient.PoolFirst,
|
||||
PoolSize: 0,
|
||||
Conns: []*config.RemoteHost{
|
||||
{
|
||||
ID: "",
|
||||
Address: "error",
|
||||
Transport: "",
|
||||
Synchronous: false,
|
||||
TLS: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
connMng := engine.NewConnManager(cfg, nil)
|
||||
dsp := NewDispatcherService(nil, cfg, nil, connMng)
|
||||
err := dsp.authorize("", "cgrates.org", utils.APIMethods, nil)
|
||||
expected := "dial tcp: address error: missing port in address"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user