diff options
author | Wolfy-J <[email protected]> | 2019-12-23 14:43:47 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2019-12-23 14:43:47 +0300 |
commit | c7b0a4a81827284f7565c56aa476eea34fb6382f (patch) | |
tree | ee30e93169c37fb058fbe55af6b3f954eabd9646 /service/rpc/config_test.go | |
parent | 7f694966730f6dac09d0d0ea3bf51276b8e4dfe4 (diff) |
- test fixes
Diffstat (limited to 'service/rpc/config_test.go')
-rw-r--r-- | service/rpc/config_test.go | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/service/rpc/config_test.go b/service/rpc/config_test.go index af261698..6791128b 100644 --- a/service/rpc/config_test.go +++ b/service/rpc/config_test.go @@ -40,7 +40,12 @@ func TestConfig_Listener(t *testing.T) { ln, err := cfg.Listener() assert.NoError(t, err) assert.NotNil(t, ln) - defer ln.Close() + defer func() { + err := ln.Close() + if err != nil { + t.Errorf("error closing the listener: error %v", err) + } + }() assert.Equal(t, "tcp", ln.Addr().Network()) assert.Equal(t, "[::]:18001", ln.Addr().String()) @@ -56,7 +61,12 @@ func TestConfig_ListenerUnix(t *testing.T) { ln, err := cfg.Listener() assert.NoError(t, err) assert.NotNil(t, ln) - defer ln.Close() + defer func() { + err := ln.Close() + if err != nil { + t.Errorf("error closing the listener: error %v", err) + } + }() assert.Equal(t, "unix", ln.Addr().Network()) assert.Equal(t, "file.sock", ln.Addr().String()) @@ -86,12 +96,22 @@ func TestConfig_Dialer(t *testing.T) { cfg := &Config{Listen: "tcp://:18001"} ln, _ := cfg.Listener() - defer ln.Close() + defer func() { + err := ln.Close() + if err != nil { + t.Errorf("error closing the listener: error %v", err) + } + }() conn, err := cfg.Dialer() assert.NoError(t, err) assert.NotNil(t, conn) - defer conn.Close() + defer func() { + err := conn.Close() + if err != nil { + t.Errorf("error closing the connection: error %v", err) + } + }() assert.Equal(t, "tcp", conn.RemoteAddr().Network()) assert.Equal(t, "127.0.0.1:18001", conn.RemoteAddr().String()) @@ -105,12 +125,22 @@ func TestConfig_DialerUnix(t *testing.T) { cfg := &Config{Listen: "unix://file.sock"} ln, _ := cfg.Listener() - defer ln.Close() + defer func() { + err := ln.Close() + if err != nil { + t.Errorf("error closing the listener: error %v", err) + } + }() conn, err := cfg.Dialer() assert.NoError(t, err) assert.NotNil(t, conn) - defer conn.Close() + defer func() { + err := conn.Close() + if err != nil { + t.Errorf("error closing the connection: error %v", err) + } + }() assert.Equal(t, "unix", conn.RemoteAddr().Network()) assert.Equal(t, "file.sock", conn.RemoteAddr().String()) @@ -138,7 +168,10 @@ func Test_Config_DialerErrorMethod(t *testing.T) { func Test_Config_Defaults(t *testing.T) { c := &Config{} - c.InitDefaults() + err := c.InitDefaults() + if err != nil { + t.Errorf("error during the InitDefaults: error %v", err) + } assert.Equal(t, true, c.Enable) assert.Equal(t, "tcp://127.0.0.1:6001", c.Listen) } |