summaryrefslogtreecommitdiff
path: root/tests/plugins/rpc/config_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-08-19 19:38:52 +0300
committerValery Piashchynski <[email protected]>2021-08-19 19:38:52 +0300
commitbea5916c57469cd75102cde07a7a6c62914c74f0 (patch)
tree3b5bde4c20d705b4742f1c80b9ebcc5e02372c3a /tests/plugins/rpc/config_test.go
parent324407b3e2d779143be65872993c4d091abb1d38 (diff)
Add support for the IPv6
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'tests/plugins/rpc/config_test.go')
-rwxr-xr-xtests/plugins/rpc/config_test.go41
1 files changed, 35 insertions, 6 deletions
diff --git a/tests/plugins/rpc/config_test.go b/tests/plugins/rpc/config_test.go
index 34ca9cee..0645050d 100755
--- a/tests/plugins/rpc/config_test.go
+++ b/tests/plugins/rpc/config_test.go
@@ -1,7 +1,6 @@
package rpc
import (
- "runtime"
"testing"
"github.com/spiral/roadrunner/v2/plugins/rpc"
@@ -22,11 +21,41 @@ func TestConfig_Listener(t *testing.T) {
}()
assert.Equal(t, "tcp", ln.Addr().Network())
- if runtime.GOOS == "windows" {
- assert.Equal(t, "[::]:18001", ln.Addr().String())
- } else {
- assert.Equal(t, "0.0.0.0:18001", ln.Addr().String())
- }
+ assert.Equal(t, "0.0.0.0:18001", ln.Addr().String())
+}
+
+func TestConfig_Listener2(t *testing.T) {
+ cfg := &rpc.Config{Listen: ":18001"}
+
+ ln, err := cfg.Listener()
+ assert.NoError(t, err)
+ assert.NotNil(t, ln)
+ 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, "0.0.0.0:18001", ln.Addr().String())
+}
+
+func TestConfig_ListenerIPV6(t *testing.T) {
+ cfg := &rpc.Config{Listen: "tcp://[::]:18001"}
+
+ ln, err := cfg.Listener()
+ assert.NoError(t, err)
+ assert.NotNil(t, ln)
+ 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())
}
func TestConfig_ListenerUnix(t *testing.T) {