fix ipv6 addr parsing and using

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2019-07-17 10:38:50 +03:00
parent d4fefc4b76
commit e688ab0a45
8 changed files with 104 additions and 68 deletions

View File

@@ -1,15 +1,17 @@
package grpc
import (
"strings"
"net"
"testing"
"github.com/micro/go-micro/transport"
)
func expectedPort(t *testing.T, expected string, lsn transport.Listener) {
parts := strings.Split(lsn.Addr(), ":")
port := parts[len(parts)-1]
_, port, err := net.SplitHostPort(lsn.Addr())
if err != nil {
t.Errorf("Expected address to be `%s`, got error: %v", expected, err)
}
if port != expected {
lsn.Close()