mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #14409 from vdemeester/fix-testRequires-network
Fix integration tests with testRequires(c, Network)
This commit is contained in:
commit
58edd21c05
1 changed files with 13 additions and 1 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
@ -37,7 +38,18 @@ var (
|
|||
}
|
||||
Network = TestRequirement{
|
||||
func() bool {
|
||||
resp, err := http.Get("http://hub.docker.com")
|
||||
// Set a timeout on the GET at 15s
|
||||
var timeout = time.Duration(15 * time.Second)
|
||||
var url = "https://hub.docker.com"
|
||||
|
||||
client := http.Client{
|
||||
Timeout: timeout,
|
||||
}
|
||||
|
||||
resp, err := client.Get(url)
|
||||
if err != nil && strings.Contains(err.Error(), "use of closed network connection") {
|
||||
panic(fmt.Sprintf("Timeout for GET request on %s", url))
|
||||
}
|
||||
if resp != nil {
|
||||
resp.Body.Close()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue