github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/tools/terraform-bundle/e2etest/main_test.go (about)

     1  package e2etest
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/e2e"
     8  )
     9  
    10  var bundleBin string
    11  
    12  func TestMain(m *testing.M) {
    13  	teardown := setup()
    14  	code := m.Run()
    15  	teardown()
    16  	os.Exit(code)
    17  }
    18  
    19  func setup() func() {
    20  	tmpFilename := e2e.GoBuild("github.com/hashicorp/terraform/tools/terraform-bundle", "terraform-bundle")
    21  	bundleBin = tmpFilename
    22  
    23  	return func() {
    24  		os.Remove(tmpFilename)
    25  	}
    26  }
    27  
    28  func canAccessNetwork() bool {
    29  	// We re-use the flag normally used for acceptance tests since that's
    30  	// established as a way to opt-in to reaching out to real systems that
    31  	// may suffer transient errors.
    32  	return os.Getenv("TF_ACC") != ""
    33  }
    34  
    35  func skipIfCannotAccessNetwork(t *testing.T) {
    36  	if !canAccessNetwork() {
    37  		t.Skip("network access not allowed; use TF_ACC=1 to enable")
    38  	}
    39  }