diff options
Diffstat (limited to 'cmd/swarm/config_test.go')
-rw-r--r-- | cmd/swarm/config_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/swarm/config_test.go b/cmd/swarm/config_test.go index d5011e3a7..02198f878 100644 --- a/cmd/swarm/config_test.go +++ b/cmd/swarm/config_test.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "io/ioutil" + "net" "os" "os/exec" "testing" @@ -559,3 +560,16 @@ func TestValidateConfig(t *testing.T) { } } } + +func assignTCPPort() (string, error) { + l, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + return "", err + } + l.Close() + _, port, err := net.SplitHostPort(l.Addr().String()) + if err != nil { + return "", err + } + return port, nil +} |