Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tfexec/internal/e2etest/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestApply(t *testing.T) {
func TestApplyJSON_TF014AndEarlier(t *testing.T) {
versions := []string{testutil.Latest011, testutil.Latest012, testutil.Latest013, testutil.Latest014}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand All @@ -47,7 +47,7 @@ func TestApplyJSON_TF014AndEarlier(t *testing.T) {
func TestApplyJSON_TF015AndLater(t *testing.T) {
versions := []string{testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions tfexec/internal/e2etest/destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestDestroy(t *testing.T) {
func TestDestroyJSON_TF014AndEarlier(t *testing.T) {
versions := []string{testutil.Latest011, testutil.Latest012, testutil.Latest013, testutil.Latest014}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand All @@ -52,7 +52,7 @@ func TestDestroyJSON_TF014AndEarlier(t *testing.T) {
func TestDestroyJSON_TF015AndLater(t *testing.T) {
versions := []string{testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions tfexec/internal/e2etest/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestPlanWithState(t *testing.T) {
func TestPlanJSON_TF014AndEarlier(t *testing.T) {
versions := []string{testutil.Latest011, testutil.Latest012, testutil.Latest013, testutil.Latest014}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand All @@ -74,7 +74,7 @@ func TestPlanJSON_TF014AndEarlier(t *testing.T) {
func TestPlanJSON_TF015AndLater(t *testing.T) {
versions := []string{testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions tfexec/internal/e2etest/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestRefresh(t *testing.T) {
func TestRefreshJSON_TF014AndEarlier(t *testing.T) {
versions := []string{testutil.Latest011, testutil.Latest012, testutil.Latest013, testutil.Latest014}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand All @@ -52,7 +52,7 @@ func TestRefreshJSON_TF014AndEarlier(t *testing.T) {
func TestRefreshJSON_TF015AndLater(t *testing.T) {
versions := []string{testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}

runTestWithVersions(t, "basic", versions, func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, versions, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand Down
22 changes: 11 additions & 11 deletions tfexec/internal/e2etest/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestShow_noInitBasic(t *testing.T) {
// no providers to download, this is unintended behaviour, as
// init is not actually necessary. This is considered a known issue in
// pre-1.2.0 versions.
runTestVersions(t, []string{testutil.Latest012, testutil.Latest013, testutil.Latest014, testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest012, testutil.Latest013, testutil.Latest014, testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
var noInit *tfexec.ErrNoInit
_, err := tf.Show(context.Background())
if !errors.As(err, &noInit) {
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestShow_noInitModule(t *testing.T) {
// no providers to download, this is unintended behaviour, as
// init is not actually necessary. This is considered a known issue in
// pre-1.2.0 versions.
runTestVersions(t, []string{testutil.Latest012, testutil.Latest013, testutil.Latest014, testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}, "registry_module", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest012, testutil.Latest013, testutil.Latest014, testutil.Latest015, testutil.Latest_v1, testutil.Latest_v1_1}, "registry_module", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
var noInit *tfexec.ErrNoInit
_, err := tf.Show(context.Background())
if !errors.As(err, &noInit) {
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestShow_versionMismatch(t *testing.T) {
// so we maintain one fixture per supported version.
// See github.com/hashicorp/terraform/25920
func TestShowStateFile012(t *testing.T) {
runTestVersions(t, []string{testutil.Latest012}, "non_default_statefile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest012}, "non_default_statefile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
expected := &tfjson.State{
FormatVersion: "0.1",
// TerraformVersion is ignored to facilitate latest version testing
Expand Down Expand Up @@ -344,7 +344,7 @@ func TestShowStateFile012(t *testing.T) {
}

func TestShowStateFile013(t *testing.T) {
runTestVersions(t, []string{testutil.Latest013, testutil.Latest014}, "non_default_statefile_013", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest013, testutil.Latest014}, "non_default_statefile_013", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
expected := &tfjson.State{
FormatVersion: "0.1",
// TerraformVersion is ignored to facilitate latest version testing
Expand Down Expand Up @@ -382,7 +382,7 @@ func TestShowStateFile013(t *testing.T) {
}

func TestShowStateFile014(t *testing.T) {
runTestVersions(t, []string{testutil.Latest014}, "non_default_statefile_014", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest014}, "non_default_statefile_014", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
expected := &tfjson.State{
FormatVersion: "0.1",
// TerraformVersion is ignored to facilitate latest version testing
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestShowStateFile014(t *testing.T) {
// Plan files cannot be transferred between different Terraform versions,
// so we maintain one fixture per supported version
func TestShowPlanFile012_linux(t *testing.T) {
runTestVersions(t, []string{testutil.Latest012}, "non_default_planfile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest012}, "non_default_planfile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
if runtime.GOOS != "linux" {
t.Skip("plan file created in 0.12 on Linux is not compatible with other systems")
}
Expand Down Expand Up @@ -488,7 +488,7 @@ func TestShowPlanFile012_linux(t *testing.T) {
}

func TestShowPlanFile013(t *testing.T) {
runTestVersions(t, []string{testutil.Latest013}, "non_default_planfile_013", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest013}, "non_default_planfile_013", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
providerName := "registry.terraform.io/hashicorp/null"

expected := &tfjson.Plan{
Expand Down Expand Up @@ -550,7 +550,7 @@ func TestShowPlanFile013(t *testing.T) {
}

func TestShowPlanFile014(t *testing.T) {
runTestVersions(t, []string{testutil.Latest014}, "non_default_planfile_014", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest014}, "non_default_planfile_014", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
providerName := "registry.terraform.io/hashicorp/null"

expected := &tfjson.Plan{
Expand Down Expand Up @@ -615,7 +615,7 @@ func TestShowPlanFile014(t *testing.T) {
}

func TestShowPlanFileRaw012_linux(t *testing.T) {
runTestVersions(t, []string{testutil.Latest012}, "non_default_planfile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest012}, "non_default_planfile_012", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
if runtime.GOOS != "linux" {
t.Skip("plan file created in 0.12 on Linux is not compatible with other systems")
}
Expand Down Expand Up @@ -647,7 +647,7 @@ func TestShowPlanFileRaw012_linux(t *testing.T) {
}

func TestShowPlanFileRaw013(t *testing.T) {
runTestVersions(t, []string{testutil.Latest013}, "non_default_planfile_013", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest013}, "non_default_planfile_013", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
f, err := os.Open("testdata/non_default_planfile_013/human_readable_output.txt")
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -675,7 +675,7 @@ func TestShowPlanFileRaw013(t *testing.T) {
}

func TestShowPlanFileRaw014(t *testing.T) {
runTestVersions(t, []string{testutil.Latest014}, "non_default_planfile_014", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest014}, "non_default_planfile_014", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
f, err := os.Open("testdata/non_default_planfile_013/human_readable_output.txt")
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion tfexec/internal/e2etest/upgrade012_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestUpgrade012(t *testing.T) {
runTestVersions(t, []string{testutil.Latest012}, "pre_011_syntax", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
runTestWithVersions(t, []string{testutil.Latest012}, "pre_011_syntax", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
Expand Down
10 changes: 2 additions & 8 deletions tfexec/internal/e2etest/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ func runTest(t *testing.T, fixtureName string, cb func(t *testing.T, tfVersion *
versions = strings.Split(override, ",")
}

runTestWithVersions(t, fixtureName, versions, cb)
}

func runTestWithVersions(t *testing.T, fixtureName string, versions []string, cb func(t *testing.T, tfVersion *version.Version, tf *tfexec.Terraform)) {
t.Helper()

// If the env var TFEXEC_E2ETEST_TERRAFORM_PATH is set to the path of a
// valid Terraform executable, only tests appropriate to that
// executable's version will be run.
Expand Down Expand Up @@ -79,10 +73,10 @@ func runTestWithVersions(t *testing.T, fixtureName string, versions []string, cb
versions = []string{lVersion.String()}
}

runTestVersions(t, versions, fixtureName, cb)
runTestWithVersions(t, versions, fixtureName, cb)
}

func runTestVersions(t *testing.T, versions []string, fixtureName string, cb func(t *testing.T, tfVersion *version.Version, tf *tfexec.Terraform)) {
func runTestWithVersions(t *testing.T, versions []string, fixtureName string, cb func(t *testing.T, tfVersion *version.Version, tf *tfexec.Terraform)) {
t.Helper()

alreadyRunVersions := map[string]bool{}
Expand Down