forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 2
/
remotetests.go
27 lines (23 loc) · 901 Bytes
/
remotetests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package acctest
import (
"net/http"
"os"
"testing"
)
// SkipRemoteTestsEnvVar is an environment variable that can be set by a user
// running the tests in an environment with limited network connectivity. By
// default, tests requiring internet connectivity make an effort to skip if no
// internet is available, but in some cases the smoke test will pass even
// though the test should still be skipped.
const SkipRemoteTestsEnvVar = "TF_SKIP_REMOTE_TESTS"
// RemoteTestPrecheck is meant to be run by any unit test that requires
// outbound internet connectivity. The test will be skipped if it's
// unavailable.
func RemoteTestPrecheck(t *testing.T) {
if os.Getenv(SkipRemoteTestsEnvVar) != "" {
t.Skipf("skipping test, %s was set", SkipRemoteTestsEnvVar)
}
if _, err := http.Get("http://google.com"); err != nil {
t.Skipf("skipping, internet seems to not be available: %s", err)
}
}