mirror of https://github.com/hashicorp/terraform
Adds the `TF_SKIP_REMOTE_TESTS` env var to be used in cases where the `http.Get()` smoke test passes but the network is not able to service the needs of the tests. Fixes #4421pull/4788/head
parent
a83d1bab23
commit
6bafa74011
@ -0,0 +1,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)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue