summaryrefslogtreecommitdiff
path: root/internal/rpc/client_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2022-03-06 12:13:02 +0100
committerValery Piashchynski <[email protected]>2022-03-06 12:13:02 +0100
commit70e4f020afd0352dc52114651f0f65c1965ed399 (patch)
treecc6595214e4ff39600099fb8c6f39e7a3dd560e9 /internal/rpc/client_test.go
parent587702be62b65c151d27dc79e62fcbbd11290e6f (diff)
remove config plugin usage from the root
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'internal/rpc/client_test.go')
-rw-r--r--internal/rpc/client_test.go21
1 files changed, 6 insertions, 15 deletions
diff --git a/internal/rpc/client_test.go b/internal/rpc/client_test.go
index 34240826..0744e167 100644
--- a/internal/rpc/client_test.go
+++ b/internal/rpc/client_test.go
@@ -14,28 +14,22 @@ func TestNewClient_RpcServiceDisabled(t *testing.T) {
cfgPlugin := &config.Plugin{Type: "yaml", ReadInCfg: []byte{}}
assert.NoError(t, cfgPlugin.Init())
- c, err := rpc.NewClient(cfgPlugin)
+ c, err := rpc.NewClient("test/config_rpc_empty.yaml")
assert.Nil(t, c)
assert.EqualError(t, err, "rpc service disabled")
}
func TestNewClient_WrongRcpConfiguration(t *testing.T) {
- cfgPlugin := &config.Plugin{Type: "yaml", ReadInCfg: []byte("rpc:\n $foo bar")}
- assert.NoError(t, cfgPlugin.Init())
-
- c, err := rpc.NewClient(cfgPlugin)
+ c, err := rpc.NewClient("test/config_rpc_wrong.yaml")
assert.Nil(t, c)
assert.Error(t, err)
- assert.Contains(t, err.Error(), "config_plugin_unmarshal_key")
+ assert.Contains(t, err.Error(), "'' expected a map, got 'string'")
}
func TestNewClient_ConnectionError(t *testing.T) {
- cfgPlugin := &config.Plugin{Type: "yaml", ReadInCfg: []byte("rpc:\n listen: tcp://127.0.0.1:0")}
- assert.NoError(t, cfgPlugin.Init())
-
- c, err := rpc.NewClient(cfgPlugin)
+ c, err := rpc.NewClient("test/config_rpc_conn_err.yaml")
assert.Nil(t, c)
assert.Error(t, err)
@@ -43,15 +37,12 @@ func TestNewClient_ConnectionError(t *testing.T) {
}
func TestNewClient_SuccessfullyConnected(t *testing.T) {
- l, err := net.Listen("tcp", "127.0.0.1:0")
+ l, err := net.Listen("tcp", "127.0.0.1:55555")
assert.NoError(t, err)
defer func() { assert.NoError(t, l.Close()) }()
- cfgPlugin := &config.Plugin{Type: "yaml", ReadInCfg: []byte("rpc:\n listen: tcp://" + l.Addr().String())}
- assert.NoError(t, cfgPlugin.Init())
-
- c, err := rpc.NewClient(cfgPlugin)
+ c, err := rpc.NewClient("test/config_rpc_ok.yaml")
assert.NotNil(t, c)
assert.NoError(t, err)