Skip to content

Commit

Permalink
remove code specific to Go<1.14
Browse files Browse the repository at this point in the history
The testTempDir() function made use of t.Cleanup(), which was not available
until Go 1.14.
  • Loading branch information
kmoe committed Oct 21, 2021
1 parent 13740b9 commit eccad43
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 52 deletions.
2 changes: 1 addition & 1 deletion tfexec/add_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestAddCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1_1))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/apply_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestApplyCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/destroy_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestDestroyCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/fmt_test.go
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestFormat(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, "0.7.6"))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/get_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestGetCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/import_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestImportCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/init_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestInitCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
24 changes: 0 additions & 24 deletions tfexec/internal/testutil/temp_dir.go

This file was deleted.

2 changes: 1 addition & 1 deletion tfexec/output_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestOutputCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/plan_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestPlanCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest_v1))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/providers_lock_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestProvidersLockCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/providers_schema_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestProvidersSchemaCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/refresh_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestRefreshCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest013))
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions tfexec/show_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestShowCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand All @@ -29,7 +29,7 @@ func TestShowCmd(t *testing.T) {
}

func TestShowStateFileCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand All @@ -50,7 +50,7 @@ func TestShowStateFileCmd(t *testing.T) {
}

func TestShowPlanFileCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand All @@ -71,7 +71,7 @@ func TestShowPlanFileCmd(t *testing.T) {
}

func TestShowPlanFileRawCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/state_mv_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestStateMvCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest013))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfexec/state_rm_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestStateRmCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest013))
if err != nil {
Expand Down
10 changes: 3 additions & 7 deletions tfexec/terraform_test.go
Expand Up @@ -28,7 +28,7 @@ func TestMain(m *testing.M) {
}

func TestSetEnv(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestSetEnv(t *testing.T) {
}

func TestCheckpointDisablePropagation(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
if err != nil {
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestCheckpointDisablePropagation(t *testing.T) {
// test that a suitable error is returned if NewTerraform is called without a valid
// executable path
func TestNoTerraformBinary(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

_, err := NewTerraform(td, "")
if err == nil {
Expand All @@ -156,10 +156,6 @@ func TestNoTerraformBinary(t *testing.T) {
}
}

func testTempDir(t *testing.T) string {
return testutil.TempDir(t)
}

func tfVersion(t *testing.T, v string) string {
if tfCache == nil {
t.Fatalf("tfCache not yet configured, TestMain must run first")
Expand Down
2 changes: 1 addition & 1 deletion tfexec/upgrade012_test.go
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestUpgrade012(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

t.Run("defaults", func(t *testing.T) {
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest012))
Expand Down
2 changes: 1 addition & 1 deletion tfexec/upgrade013_test.go
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestUpgrade013(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

t.Run("defaults", func(t *testing.T) {
tf, err := NewTerraform(td, tfVersion(t, testutil.Latest013))
Expand Down
2 changes: 1 addition & 1 deletion tfexec/workspace_new_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestWorkspaceNewCmd(t *testing.T) {
td := testTempDir(t)
td := t.TempDir()

tf, err := NewTerraform(td, tfVersion(t, testutil.Latest013))
if err != nil {
Expand Down

0 comments on commit eccad43

Please sign in to comment.