|
@@ -5,21 +5,16 @@ import (
|
|
|
"strings"
|
|
|
"testing"
|
|
|
"time"
|
|
|
-
|
|
|
- "github.com/gotestyourself/gotestyourself/skip"
|
|
|
)
|
|
|
|
|
|
// HasHubConnectivity checks to see if https://hub.docker.com is
|
|
|
// accessible from the present environment
|
|
|
-func HasHubConnectivity(t *testing.T) {
|
|
|
+func HasHubConnectivity(t *testing.T) bool {
|
|
|
// Set a timeout on the GET at 15s
|
|
|
var timeout = 15 * time.Second
|
|
|
var url = "https://hub.docker.com"
|
|
|
|
|
|
- client := http.Client{
|
|
|
- Timeout: timeout,
|
|
|
- }
|
|
|
-
|
|
|
+ client := http.Client{Timeout: timeout}
|
|
|
resp, err := client.Get(url)
|
|
|
if err != nil && strings.Contains(err.Error(), "use of closed network connection") {
|
|
|
t.Fatalf("Timeout for GET request on %s", url)
|
|
@@ -27,5 +22,5 @@ func HasHubConnectivity(t *testing.T) {
|
|
|
if resp != nil {
|
|
|
resp.Body.Close()
|
|
|
}
|
|
|
- skip.IfCondition(t, err != nil)
|
|
|
+ return err == nil
|
|
|
}
|