From: Matt Joiner Date: Thu, 20 Nov 2014 02:01:03 +0000 (-0600) Subject: torrentfs tests: Use dynamic port X-Git-Tag: v1.0.0~1498 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=8518b54cde319b4b35e02f740c87cf614130c438;p=btrtrc.git torrentfs tests: Use dynamic port --- diff --git a/fs/torrentfs_test.go b/fs/torrentfs_test.go index 8c48a006..ba8b5a48 100644 --- a/fs/torrentfs_test.go +++ b/fs/torrentfs_test.go @@ -28,12 +28,7 @@ func init() { } func TestTCPAddrString(t *testing.T) { - ta := &net.TCPAddr{ - IP: net.IPv4(127, 0, 0, 1), - Port: 3000, - } - s := ta.String() - l, err := net.Listen("tcp4", "localhost:3000") + l, err := net.Listen("tcp4", "localhost:0") if err != nil { t.Fatal(err) } @@ -44,6 +39,11 @@ func TestTCPAddrString(t *testing.T) { } defer c.Close() ras := c.RemoteAddr().String() + ta := &net.TCPAddr{ + IP: net.IPv4(127, 0, 0, 1), + Port: util.AddrPort(l.Addr()), + } + s := ta.String() if ras != s { t.FailNow() }