Skip to content

Commit

Permalink
flathttp/test: have getAvailableAddrs guarantee to not emit duplicate…
Browse files Browse the repository at this point in the history
… available bind addrs
  • Loading branch information
lithdew committed May 24, 2020
1 parent 5f3270d commit bc32326
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion flathttp/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ import (
func getAvailableAddrs(t testing.TB, scheme string, n int) []string {
t.Helper()

lns := make([]net.Listener, 0, n)
addrs := make([]string, 0, n)
for i := 0; i < n; i++ {
ln, err := net.Listen(scheme, ":0")
require.NoError(t, err)
require.NoError(t, ln.Close())

lns = append(lns, ln)
addrs = append(addrs, scheme+"://"+ln.Addr().String())
}
for _, ln := range lns {
require.NoError(t, ln.Close())
}
return addrs
}

Expand Down

0 comments on commit bc32326

Please sign in to comment.