mirror of
https://github.com/rclone/rclone.git
synced 2026-01-06 10:33:34 +00:00
tests: make test servers choose a random port to make more reliable
Tests have been randomly failing with messages like
listen tcp 127.0.0.1:51778: bind: address already in use
Rework all the test servers so they choose a random free port on
startup and use that for the tests to avoid.
This commit is contained in:
@@ -20,11 +20,11 @@ import (
|
||||
|
||||
var (
|
||||
dlnaServer *server
|
||||
testURL string
|
||||
)
|
||||
|
||||
const (
|
||||
testBindAddress = "localhost:51777"
|
||||
testURL = "http://" + testBindAddress + "/"
|
||||
testBindAddress = "localhost:0"
|
||||
)
|
||||
|
||||
func startServer(t *testing.T, f fs.Fs) {
|
||||
@@ -32,6 +32,7 @@ func startServer(t *testing.T, f fs.Fs) {
|
||||
opt.ListenAddr = testBindAddress
|
||||
dlnaServer = newServer(f, &opt)
|
||||
assert.NoError(t, dlnaServer.Serve())
|
||||
testURL = "http://" + dlnaServer.HTTPConn.Addr().String() + "/"
|
||||
}
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user