@@ -20,7 +20,6 @@ import (
2020 dsql "database/sql"
2121 "fmt"
2222 "io"
23- "net"
2423 "os"
2524 "reflect"
2625 "strings"
@@ -2144,7 +2143,8 @@ func TestUserAuthentication(t *testing.T, h Harness) {
21442143 }
21452144 clientHarness .Setup (setup .MydbData , setup .MytableData )
21462145
2147- port := getEmptyPort (t )
2146+ port , err := sql .GetEmptyPort ()
2147+ require .NoError (t , err )
21482148 for _ , script := range queries .ServerAuthTests {
21492149 t .Run (script .Name , func (t * testing.T ) {
21502150 ctx := NewContextWithClient (clientHarness , sql.Client {
@@ -2240,14 +2240,6 @@ func TestUserAuthentication(t *testing.T, h Harness) {
22402240 }
22412241}
22422242
2243- func getEmptyPort (t * testing.T ) int {
2244- listener , err := net .Listen ("tcp" , ":0" )
2245- require .NoError (t , err )
2246- port := listener .Addr ().(* net.TCPAddr ).Port
2247- require .NoError (t , listener .Close ())
2248- return port
2249- }
2250-
22512243func TestComplexIndexQueries (t * testing.T , harness Harness ) {
22522244 harness .Setup (setup .ComplexIndexSetup ... )
22532245 e := mustNewEngine (t , harness )
@@ -5725,7 +5717,8 @@ func testCharsetCollationWire(t *testing.T, h Harness, sessionBuilder server.Ses
57255717 harness .Setup (setup .MydbData )
57265718 }
57275719
5728- port := getEmptyPort (t )
5720+ port , err := sql .GetEmptyPort ()
5721+ require .NoError (t , err )
57295722 for _ , script := range tests {
57305723 t .Run (script .Name , func (t * testing.T ) {
57315724 serverConfig := server.Config {
@@ -5829,7 +5822,8 @@ func extractCollationIdForField(r *dsql.Rows, i int) uint64 {
58295822func TestTypesOverWire (t * testing.T , harness ClientHarness , sessionBuilder server.SessionBuilder ) {
58305823 harness .Setup (setup .MydbData )
58315824
5832- port := getEmptyPort (t )
5825+ port , err := sql .GetEmptyPort ()
5826+ require .NoError (t , err )
58335827 for _ , script := range queries .TypeWireTests {
58345828 t .Run (script .Name , func (t * testing.T ) {
58355829 e := mustNewEngine (t , harness )
0 commit comments