Skip to content

Commit

Permalink
Move skip calls into helper
Browse files Browse the repository at this point in the history
  • Loading branch information
minamijoyo committed Jul 28, 2020
1 parent aff51df commit 3c7d551
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 24 deletions.
8 changes: 5 additions & 3 deletions tfexec/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ func setupTestAcc(t *testing.T, source string) Executor {
return e
}

// isAcceptanceTestEnabled returns true if acceptance tests should be run.
func isAcceptanceTestEnabled() bool {
return os.Getenv("TEST_ACC") == "1"
// SkipUnlessAcceptanceTestEnabled skips acceptance tests unless TEST_ACC is set to 1.
func SkipUnlessAcceptanceTestEnabled(t *testing.T) {
if os.Getenv("TEST_ACC") != "1" {
t.Skip("skip acceptance tests")
}
}

// setupTestWorkDir creates temporary working directory with a given source for testing.
Expand Down
4 changes: 1 addition & 3 deletions tfexec/terraform_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ func TestTerraformCLIApply(t *testing.T) {
}

func TestAccTerraformCLIApply(t *testing.T) {
if !isAcceptanceTestEnabled() {
t.Skip("skip acceptance tests")
}
SkipUnlessAcceptanceTestEnabled(t)

source := `resource "null_resource" "foo" {}`
e := setupTestAcc(t, source)
Expand Down
4 changes: 1 addition & 3 deletions tfexec/terraform_destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ func TestTerraformCLIDestroy(t *testing.T) {
}

func TestAccTerraformCLIDestroy(t *testing.T) {
if !isAcceptanceTestEnabled() {
t.Skip("skip acceptance tests")
}
SkipUnlessAcceptanceTestEnabled(t)

source := `resource "null_resource" "foo" {}`
e := setupTestAcc(t, source)
Expand Down
4 changes: 1 addition & 3 deletions tfexec/terraform_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ func TestTerraformCLIImport(t *testing.T) {
}

func TestAccTerraformCLIImport(t *testing.T) {
if !isAcceptanceTestEnabled() {
t.Skip("skip acceptance tests")
}
SkipUnlessAcceptanceTestEnabled(t)

source := `
resource "random_string" "foo" {
Expand Down
4 changes: 1 addition & 3 deletions tfexec/terraform_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ func TestTerraformCLIInit(t *testing.T) {
}

func TestAccTerraformCLIInit(t *testing.T) {
if !isAcceptanceTestEnabled() {
t.Skip("skip acceptance tests")
}
SkipUnlessAcceptanceTestEnabled(t)

source := `resource "null_resource" "foo" {}`
e := setupTestAcc(t, source)
Expand Down
4 changes: 1 addition & 3 deletions tfexec/terraform_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ func TestTerraformCLIPlan(t *testing.T) {
}

func TestAccTerraformCLIPlan(t *testing.T) {
if !isAcceptanceTestEnabled() {
t.Skip("skip acceptance tests")
}
SkipUnlessAcceptanceTestEnabled(t)

source := `resource "null_resource" "foo" {}`
e := setupTestAcc(t, source)
Expand Down
4 changes: 1 addition & 3 deletions tfexec/terraform_state_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ aws_security_group.foo
}

func TestAccTerraformCLIStateList(t *testing.T) {
if !isAcceptanceTestEnabled() {
t.Skip("skip acceptance tests")
}
SkipUnlessAcceptanceTestEnabled(t)

source := `
resource "null_resource" "foo" {}
Expand Down
4 changes: 1 addition & 3 deletions tfexec/terraform_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ is 0.12.29. You can update by downloading from https://www.terraform.io/download
}

func TestAccTerraformCLIVersion(t *testing.T) {
if !isAcceptanceTestEnabled() {
t.Skip("skip acceptance tests")
}
SkipUnlessAcceptanceTestEnabled(t)

e := NewExecutor("", os.Environ())
terraformCLI := NewTerraformCLI(e)
Expand Down

0 comments on commit 3c7d551

Please sign in to comment.