cri-o/vendor/github.com/godbus/dbus/transport_tcp_test.go
Mrunal Patel 69ed8639cd Update dependencies to include github.com/godbus/dbus
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2017-03-01 16:49:45 -08:00

26 lines
508 B
Go

package dbus
import (
"fmt"
"net"
"testing"
)
func TestTcpConnection(t *testing.T) {
listener, err := net.Listen("tcp", ":0")
if err != nil {
t.Fatal("Failed to create listener")
}
host, port, err := net.SplitHostPort(listener.Addr().String())
if err != nil {
t.Fatal("Failed to parse host/port")
}
conn, err := Dial(fmt.Sprintf("tcp:host=%s,port=%s", host, port))
if err != nil {
t.Error("Expected no error, got", err)
}
if conn == nil {
t.Error("Expected connection, got nil")
}
}