diff --git a/CHANGELOG.md b/CHANGELOG.md index 9919a7cb81..aaecda42df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ NEW FEATURES: * `terraform test`: The previously experimental `terraform test` command has been moved out of experimental. This comes with a significant change in how Terraform tests are written and executed. - Terraform tests are now written within `.tftest` files, controlled by a series of `run` blocks. Each `run` block will execute a Terraform plan or apply command against the Terraform configuration under test and can execute conditions against the resultant plan and state. + Terraform tests are now written within `.tftest.hcl` files, controlled by a series of `run` blocks. Each `run` block will execute a Terraform plan or apply command against the Terraform configuration under test and can execute conditions against the resultant plan and state. ENHANCEMENTS: * config: Terraform can now track some additional detail about values that won't be known until the apply step, such as the range of possible lengths for a collection or whether an unknown value can possibly be null. When this information is available, Terraform can potentially generate known results for some operations on unknown values. This doesn't mean that Terraform can immediately track that detail in all cases, but the type system now contains the facility for that and so over time we will improve the level of detail generated by built-in functions, language operators, Terraform providers, etc. [GH-33234] diff --git a/internal/command/arguments/test_test.go b/internal/command/arguments/test_test.go index 9fd239105a..5be65c56e4 100644 --- a/internal/command/arguments/test_test.go +++ b/internal/command/arguments/test_test.go @@ -79,9 +79,9 @@ func TestParseTest(t *testing.T) { wantDiags: nil, }, "with-filters": { - args: []string{"-filter=one.tftest", "-filter=two.tftest"}, + args: []string{"-filter=one.tftest.hcl", "-filter=two.tftest.hcl"}, want: &Test{ - Filter: []string{"one.tftest", "two.tftest"}, + Filter: []string{"one.tftest.hcl", "two.tftest.hcl"}, TestDirectory: "tests", ViewType: ViewHuman, Vars: &Vars{}, diff --git a/internal/command/providers.go b/internal/command/providers.go index 25699df7ee..aaad0c2e83 100644 --- a/internal/command/providers.go +++ b/internal/command/providers.go @@ -151,7 +151,7 @@ func (c *ProvidersCommand) populateTreeNode(tree treeprint.Tree, node *configs.M tree.AddNode(fmt.Sprintf("provider[%s]%s", fqn.String(), versionsStr)) } for name, testNode := range node.Tests { - name = strings.TrimSuffix(name, ".tftest") + name = strings.TrimSuffix(name, ".tftest.hcl") name = strings.ReplaceAll(name, "/", ".") branch := tree.AddBranch(fmt.Sprintf("test.%s", name)) diff --git a/internal/command/test.go b/internal/command/test.go index a38db04320..58c8a4ef65 100644 --- a/internal/command/test.go +++ b/internal/command/test.go @@ -32,10 +32,10 @@ Usage: terraform [global options] test [options] Executes automated integration tests against the current Terraform configuration. - Terraform will search for .tftest files within the current configuration and - testing directories. Terraform will then execute the testing run blocks within - any testing files in order, and verify conditional checks and assertions - against the created infrastructure. + Terraform will search for .tftest.hcl files within the current configuration + and testing directories. Terraform will then execute the testing run blocks + within any testing files in order, and verify conditional checks and + assertions against the created infrastructure. This command creates real infrastructure and will attempt to clean up the testing infrastructure on completion. Monitor the output carefully to ensure diff --git a/internal/command/test_test.go b/internal/command/test_test.go index 3c7676971d..d988dd8cee 100644 --- a/internal/command/test_test.go +++ b/internal/command/test_test.go @@ -75,7 +75,7 @@ func TestTest(t *testing.T) { }, "multiple_files_with_filter": { override: "multiple_files", - args: []string{"-filter=one.tftest"}, + args: []string{"-filter=one.tftest.hcl"}, expected: "1 passed, 0 failed", code: 0, }, @@ -211,7 +211,7 @@ func TestTest_DoubleInterrupt(t *testing.T) { t.Errorf("output didn't produce the right output:\n\n%s", output) } - cleanupMessage := `Terraform was interrupted while executing main.tftest, and may not have + cleanupMessage := `Terraform was interrupted while executing main.tftest.hcl, and may not have performed the expected cleanup operations. Terraform has already created the following resources from the module under @@ -396,7 +396,7 @@ func TestTest_Verbose(t *testing.T) { t.Errorf("expected status code 0 but got %d", code) } - expected := `main.tftest... pass + expected := `main.tftest.hcl... pass run "validate_test_resource"... pass Terraform used the selected providers to generate the following execution diff --git a/internal/command/testdata/init-with-tests-with-module/main.tftest b/internal/command/testdata/init-with-tests-with-module/main.tftest.hcl similarity index 100% rename from internal/command/testdata/init-with-tests-with-module/main.tftest rename to internal/command/testdata/init-with-tests-with-module/main.tftest.hcl diff --git a/internal/command/testdata/init-with-tests-with-provider/main.tftest b/internal/command/testdata/init-with-tests-with-provider/main.tftest.hcl similarity index 100% rename from internal/command/testdata/init-with-tests-with-provider/main.tftest rename to internal/command/testdata/init-with-tests-with-provider/main.tftest.hcl diff --git a/internal/command/testdata/init-with-tests/main.tftest b/internal/command/testdata/init-with-tests/main.tftest.hcl similarity index 100% rename from internal/command/testdata/init-with-tests/main.tftest rename to internal/command/testdata/init-with-tests/main.tftest.hcl diff --git a/internal/command/testdata/providers/tests/main.tftest b/internal/command/testdata/providers/tests/main.tftest.hcl similarity index 100% rename from internal/command/testdata/providers/tests/main.tftest rename to internal/command/testdata/providers/tests/main.tftest.hcl diff --git a/internal/command/testdata/test/custom_condition_checks/main.tftest b/internal/command/testdata/test/custom_condition_checks/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/custom_condition_checks/main.tftest rename to internal/command/testdata/test/custom_condition_checks/main.tftest.hcl diff --git a/internal/command/testdata/test/custom_condition_inputs/main.tftest b/internal/command/testdata/test/custom_condition_inputs/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/custom_condition_inputs/main.tftest rename to internal/command/testdata/test/custom_condition_inputs/main.tftest.hcl diff --git a/internal/command/testdata/test/custom_condition_outputs/main.tftest b/internal/command/testdata/test/custom_condition_outputs/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/custom_condition_outputs/main.tftest rename to internal/command/testdata/test/custom_condition_outputs/main.tftest.hcl diff --git a/internal/command/testdata/test/custom_condition_resources/main.tftest b/internal/command/testdata/test/custom_condition_resources/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/custom_condition_resources/main.tftest rename to internal/command/testdata/test/custom_condition_resources/main.tftest.hcl diff --git a/internal/command/testdata/test/expect_failures_checks/main.tftest b/internal/command/testdata/test/expect_failures_checks/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/expect_failures_checks/main.tftest rename to internal/command/testdata/test/expect_failures_checks/main.tftest.hcl diff --git a/internal/command/testdata/test/expect_failures_inputs/main.tftest b/internal/command/testdata/test/expect_failures_inputs/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/expect_failures_inputs/main.tftest rename to internal/command/testdata/test/expect_failures_inputs/main.tftest.hcl diff --git a/internal/command/testdata/test/expect_failures_outputs/main.tftest b/internal/command/testdata/test/expect_failures_outputs/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/expect_failures_outputs/main.tftest rename to internal/command/testdata/test/expect_failures_outputs/main.tftest.hcl diff --git a/internal/command/testdata/test/expect_failures_resources/main.tftest b/internal/command/testdata/test/expect_failures_resources/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/expect_failures_resources/main.tftest rename to internal/command/testdata/test/expect_failures_resources/main.tftest.hcl diff --git a/internal/command/testdata/test/multiple_files/one.tftest b/internal/command/testdata/test/multiple_files/one.tftest.hcl similarity index 100% rename from internal/command/testdata/test/multiple_files/one.tftest rename to internal/command/testdata/test/multiple_files/one.tftest.hcl diff --git a/internal/command/testdata/test/multiple_files/two.tftest b/internal/command/testdata/test/multiple_files/two.tftest.hcl similarity index 100% rename from internal/command/testdata/test/multiple_files/two.tftest rename to internal/command/testdata/test/multiple_files/two.tftest.hcl diff --git a/internal/command/testdata/test/pass_with_locals/main.tftest b/internal/command/testdata/test/pass_with_locals/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/pass_with_locals/main.tftest rename to internal/command/testdata/test/pass_with_locals/main.tftest.hcl diff --git a/internal/command/testdata/test/pass_with_outputs/main.tftest b/internal/command/testdata/test/pass_with_outputs/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/pass_with_outputs/main.tftest rename to internal/command/testdata/test/pass_with_outputs/main.tftest.hcl diff --git a/internal/command/testdata/test/pass_with_variables/main.tftest b/internal/command/testdata/test/pass_with_variables/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/pass_with_variables/main.tftest rename to internal/command/testdata/test/pass_with_variables/main.tftest.hcl diff --git a/internal/command/testdata/test/plan_then_apply/main.tftest b/internal/command/testdata/test/plan_then_apply/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/plan_then_apply/main.tftest rename to internal/command/testdata/test/plan_then_apply/main.tftest.hcl diff --git a/internal/command/testdata/test/simple_fail/main.tftest b/internal/command/testdata/test/simple_fail/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/simple_fail/main.tftest rename to internal/command/testdata/test/simple_fail/main.tftest.hcl diff --git a/internal/command/testdata/test/simple_pass/main.tftest b/internal/command/testdata/test/simple_pass/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/simple_pass/main.tftest rename to internal/command/testdata/test/simple_pass/main.tftest.hcl diff --git a/internal/command/testdata/test/simple_pass_nested/tests/main.tftest b/internal/command/testdata/test/simple_pass_nested/tests/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/simple_pass_nested/tests/main.tftest rename to internal/command/testdata/test/simple_pass_nested/tests/main.tftest.hcl diff --git a/internal/command/testdata/test/simple_pass_nested_alternate/other/main.tftest b/internal/command/testdata/test/simple_pass_nested_alternate/other/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/simple_pass_nested_alternate/other/main.tftest rename to internal/command/testdata/test/simple_pass_nested_alternate/other/main.tftest.hcl diff --git a/internal/command/testdata/test/variables/main.tftest b/internal/command/testdata/test/variables/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/variables/main.tftest rename to internal/command/testdata/test/variables/main.tftest.hcl diff --git a/internal/command/testdata/test/variables/set_variables.tftest b/internal/command/testdata/test/variables/set_variables.tftest.hcl similarity index 100% rename from internal/command/testdata/test/variables/set_variables.tftest rename to internal/command/testdata/test/variables/set_variables.tftest.hcl diff --git a/internal/command/testdata/test/with_double_interrupt/main.tftest b/internal/command/testdata/test/with_double_interrupt/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/with_double_interrupt/main.tftest rename to internal/command/testdata/test/with_double_interrupt/main.tftest.hcl diff --git a/internal/command/testdata/test/with_interrupt/main.tftest b/internal/command/testdata/test/with_interrupt/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/with_interrupt/main.tftest rename to internal/command/testdata/test/with_interrupt/main.tftest.hcl diff --git a/internal/command/testdata/test/with_provider_alias/main.tftest b/internal/command/testdata/test/with_provider_alias/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/with_provider_alias/main.tftest rename to internal/command/testdata/test/with_provider_alias/main.tftest.hcl diff --git a/internal/command/testdata/test/with_setup_module/main.tftest b/internal/command/testdata/test/with_setup_module/main.tftest.hcl similarity index 100% rename from internal/command/testdata/test/with_setup_module/main.tftest rename to internal/command/testdata/test/with_setup_module/main.tftest.hcl diff --git a/internal/command/views/test_test.go b/internal/command/views/test_test.go index 3e04b3c4f6..f25d2b37d6 100644 --- a/internal/command/views/test_test.go +++ b/internal/command/views/test_test.go @@ -33,8 +33,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Skip, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Skip, Runs: []*moduletest.Run{ { @@ -51,8 +51,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Skip, Runs: []*moduletest.Run{ { @@ -78,8 +78,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Pass, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -96,8 +96,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -123,8 +123,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Pass, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -141,8 +141,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -168,8 +168,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Fail, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -186,8 +186,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -213,8 +213,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Fail, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -231,8 +231,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -258,8 +258,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Fail, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -276,8 +276,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -303,8 +303,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Error, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Error, Runs: []*moduletest.Run{ { @@ -321,8 +321,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Error, Runs: []*moduletest.Run{ { @@ -348,8 +348,8 @@ func TestTestHuman_Conclusion(t *testing.T) { Suite: &moduletest.Suite{ Status: moduletest.Error, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -366,8 +366,8 @@ func TestTestHuman_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Error, Runs: []*moduletest.Run{ { @@ -692,7 +692,7 @@ resource "test_resource" "creating" { for name, tc := range tcs { t.Run(name, func(t *testing.T) { file := &moduletest.File{ - Name: "main.tftest", + Name: "main.tftest.hcl", } streams, done := terminal.StreamsForTesting(t) @@ -725,7 +725,7 @@ func TestTestHuman_DestroySummary(t *testing.T) { }{ "empty": { diags: nil, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.NewState(), }, "empty_state_only_warnings": { @@ -733,7 +733,7 @@ func TestTestHuman_DestroySummary(t *testing.T) { tfdiags.Sourceless(tfdiags.Warning, "first warning", "some thing not very bad happened"), tfdiags.Sourceless(tfdiags.Warning, "second warning", "some thing not very bad happened again"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.NewState(), stdout: ` Warning: first warning @@ -751,7 +751,7 @@ some thing not very bad happened again tfdiags.Sourceless(tfdiags.Warning, "second warning", "some thing not very bad happened again"), tfdiags.Sourceless(tfdiags.Error, "first error", "this time it is very bad"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.NewState(), stdout: ` Warning: first warning @@ -763,7 +763,7 @@ Warning: second warning some thing not very bad happened again `, stderr: `Terraform encountered an error destroying resources created while executing -main.tftest. +main.tftest.hcl. Error: first error @@ -775,10 +775,10 @@ this time it is very bad tfdiags.Sourceless(tfdiags.Error, "first error", "this time it is very bad"), }, run: &moduletest.Run{Name: "run_block"}, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.NewState(), stderr: `Terraform encountered an error destroying resources created while executing -main.tftest/run_block. +main.tftest.hcl/run_block. Error: first error @@ -790,7 +790,7 @@ this time it is very bad tfdiags.Sourceless(tfdiags.Warning, "first warning", "some thing not very bad happened"), tfdiags.Sourceless(tfdiags.Warning, "second warning", "some thing not very bad happened again"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.BuildState(func(state *states.SyncState) { state.SetResourceInstanceCurrent( addrs.Resource{ @@ -843,8 +843,8 @@ Warning: second warning some thing not very bad happened again `, stderr: ` -Terraform left the following resources in state after executing main.tftest, -and they need to be cleaned up manually: +Terraform left the following resources in state after executing +main.tftest.hcl, and they need to be cleaned up manually: - test.bar - test.bar (0fcb640a) - test.foo @@ -856,7 +856,7 @@ and they need to be cleaned up manually: tfdiags.Sourceless(tfdiags.Warning, "second warning", "some thing not very bad happened again"), tfdiags.Sourceless(tfdiags.Error, "first error", "this time it is very bad"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.BuildState(func(state *states.SyncState) { state.SetResourceInstanceCurrent( addrs.Resource{ @@ -909,14 +909,14 @@ Warning: second warning some thing not very bad happened again `, stderr: `Terraform encountered an error destroying resources created while executing -main.tftest. +main.tftest.hcl. Error: first error this time it is very bad -Terraform left the following resources in state after executing main.tftest, -and they need to be cleaned up manually: +Terraform left the following resources in state after executing +main.tftest.hcl, and they need to be cleaned up manually: - test.bar - test.bar (0fcb640a) - test.foo @@ -990,7 +990,7 @@ func TestTestHuman_FatalInterruptSummary(t *testing.T) { }, }, want: ` -Terraform was interrupted while executing main.tftest, and may not have +Terraform was interrupted while executing main.tftest.hcl, and may not have performed the expected cleanup operations. Terraform was in the process of creating the following resources for @@ -1033,7 +1033,7 @@ Terraform was in the process of creating the following resources for }, created: nil, want: ` -Terraform was interrupted while executing main.tftest, and may not have +Terraform was interrupted while executing main.tftest.hcl, and may not have performed the expected cleanup operations. Terraform has already created the following resources from the module under @@ -1083,7 +1083,7 @@ test: }, created: nil, want: ` -Terraform was interrupted while executing main.tftest, and may not have +Terraform was interrupted while executing main.tftest.hcl, and may not have performed the expected cleanup operations. Terraform has already created the following resources for "setup_block" from @@ -1197,7 +1197,7 @@ Terraform has already created the following resources for "setup_block" from Name: "run_block", }, want: ` -Terraform was interrupted while executing main.tftest, and may not have +Terraform was interrupted while executing main.tftest.hcl, and may not have performed the expected cleanup operations. Terraform has already created the following resources for "setup_block" from @@ -1222,7 +1222,7 @@ Terraform was in the process of creating the following resources for streams, done := terminal.StreamsForTesting(t) view := NewTest(arguments.ViewHuman, NewView(streams)) - file := &moduletest.File{Name: "main.tftest"} + file := &moduletest.File{Name: "main.tftest.hcl"} view.FatalInterruptSummary(tc.run, file, tc.states, tc.created) actual, expected := done(t).Stderr(), tc.want @@ -1241,7 +1241,7 @@ func TestTestJSON_Abstract(t *testing.T) { "single": { suite: &moduletest.Suite{ Files: map[string]*moduletest.File{ - "main.tftest": { + "main.tftest.hcl": { Runs: []*moduletest.Run{ { Name: "setup", @@ -1256,7 +1256,7 @@ func TestTestJSON_Abstract(t *testing.T) { "@message": "Found 1 file and 1 run block", "@module": "terraform.ui", "test_abstract": map[string]interface{}{ - "main.tftest": []interface{}{ + "main.tftest.hcl": []interface{}{ "setup", }, }, @@ -1267,7 +1267,7 @@ func TestTestJSON_Abstract(t *testing.T) { "plural": { suite: &moduletest.Suite{ Files: map[string]*moduletest.File{ - "main.tftest": { + "main.tftest.hcl": { Runs: []*moduletest.Run{ { Name: "setup", @@ -1277,7 +1277,7 @@ func TestTestJSON_Abstract(t *testing.T) { }, }, }, - "other.tftest": { + "other.tftest.hcl": { Runs: []*moduletest.Run{ { Name: "test", @@ -1292,11 +1292,11 @@ func TestTestJSON_Abstract(t *testing.T) { "@message": "Found 2 files and 3 run blocks", "@module": "terraform.ui", "test_abstract": map[string]interface{}{ - "main.tftest": []interface{}{ + "main.tftest.hcl": []interface{}{ "setup", "test", }, - "other.tftest": []interface{}{ + "other.tftest.hcl": []interface{}{ "test", }, }, @@ -1344,8 +1344,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Skip, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Skip, Runs: []*moduletest.Run{ { @@ -1362,8 +1362,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Skip, Runs: []*moduletest.Run{ { @@ -1403,8 +1403,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Pass, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -1421,8 +1421,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -1462,8 +1462,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Pass, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -1480,8 +1480,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Pass, Runs: []*moduletest.Run{ { @@ -1521,8 +1521,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Fail, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -1539,8 +1539,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -1580,8 +1580,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Fail, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -1598,8 +1598,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -1639,8 +1639,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Fail, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -1657,8 +1657,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -1698,8 +1698,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Error, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Error, Runs: []*moduletest.Run{ { @@ -1716,8 +1716,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Error, Runs: []*moduletest.Run{ { @@ -1757,8 +1757,8 @@ func TestTestJSON_Conclusion(t *testing.T) { suite: &moduletest.Suite{ Status: moduletest.Error, Files: map[string]*moduletest.File{ - "descriptive_test_name.tftest": { - Name: "descriptive_test_name.tftest", + "descriptive_test_name.tftest.hcl": { + Name: "descriptive_test_name.tftest.hcl", Status: moduletest.Fail, Runs: []*moduletest.Run{ { @@ -1775,8 +1775,8 @@ func TestTestJSON_Conclusion(t *testing.T) { }, }, }, - "other_descriptive_test_name.tftest": { - Name: "other_descriptive_test_name.tftest", + "other_descriptive_test_name.tftest.hcl": { + Name: "other_descriptive_test_name.tftest.hcl", Status: moduletest.Error, Runs: []*moduletest.Run{ { @@ -1836,14 +1836,14 @@ func TestTestJSON_DestroySummary(t *testing.T) { tfdiags.Sourceless(tfdiags.Warning, "first warning", "something not very bad happened"), tfdiags.Sourceless(tfdiags.Warning, "second warning", "something not very bad happened again"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.NewState(), want: []map[string]interface{}{ { "@level": "warn", "@message": "Warning: first warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened", "severity": "warning", @@ -1855,7 +1855,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "warn", "@message": "Warning: second warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened again", "severity": "warning", @@ -1871,14 +1871,14 @@ func TestTestJSON_DestroySummary(t *testing.T) { tfdiags.Sourceless(tfdiags.Warning, "second warning", "something not very bad happened again"), tfdiags.Sourceless(tfdiags.Error, "first error", "this time it is very bad"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.NewState(), want: []map[string]interface{}{ { "@level": "warn", "@message": "Warning: first warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened", "severity": "warning", @@ -1890,7 +1890,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "warn", "@message": "Warning: second warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened again", "severity": "warning", @@ -1902,7 +1902,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "error", "@message": "Error: first error", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "this time it is very bad", "severity": "error", @@ -1913,7 +1913,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { }, }, "state_from_run": { - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, run: &moduletest.Run{Name: "run_block"}, state: states.BuildState(func(state *states.SyncState) { state.SetResourceInstanceCurrent( @@ -1933,9 +1933,9 @@ func TestTestJSON_DestroySummary(t *testing.T) { want: []map[string]interface{}{ { "@level": "error", - "@message": "Terraform left some resources in state after executing main.tftest/run_block, they need to be cleaned up manually.", + "@message": "Terraform left some resources in state after executing main.tftest.hcl/run_block, they need to be cleaned up manually.", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_cleanup": map[string]interface{}{ "failed_resources": []interface{}{ @@ -1953,7 +1953,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { tfdiags.Sourceless(tfdiags.Warning, "first warning", "something not very bad happened"), tfdiags.Sourceless(tfdiags.Warning, "second warning", "something not very bad happened again"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.BuildState(func(state *states.SyncState) { state.SetResourceInstanceCurrent( addrs.Resource{ @@ -1999,9 +1999,9 @@ func TestTestJSON_DestroySummary(t *testing.T) { want: []map[string]interface{}{ { "@level": "error", - "@message": "Terraform left some resources in state after executing main.tftest, they need to be cleaned up manually.", + "@message": "Terraform left some resources in state after executing main.tftest.hcl, they need to be cleaned up manually.", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "test_cleanup": map[string]interface{}{ "failed_resources": []interface{}{ map[string]interface{}{ @@ -2022,7 +2022,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "warn", "@message": "Warning: first warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened", "severity": "warning", @@ -2034,7 +2034,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "warn", "@message": "Warning: second warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened again", "severity": "warning", @@ -2050,7 +2050,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { tfdiags.Sourceless(tfdiags.Warning, "second warning", "something not very bad happened again"), tfdiags.Sourceless(tfdiags.Error, "first error", "this time it is very bad"), }, - file: &moduletest.File{Name: "main.tftest"}, + file: &moduletest.File{Name: "main.tftest.hcl"}, state: states.BuildState(func(state *states.SyncState) { state.SetResourceInstanceCurrent( addrs.Resource{ @@ -2096,9 +2096,9 @@ func TestTestJSON_DestroySummary(t *testing.T) { want: []map[string]interface{}{ { "@level": "error", - "@message": "Terraform left some resources in state after executing main.tftest, they need to be cleaned up manually.", + "@message": "Terraform left some resources in state after executing main.tftest.hcl, they need to be cleaned up manually.", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "test_cleanup": map[string]interface{}{ "failed_resources": []interface{}{ map[string]interface{}{ @@ -2119,7 +2119,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "warn", "@message": "Warning: first warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened", "severity": "warning", @@ -2131,7 +2131,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "warn", "@message": "Warning: second warning", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "something not very bad happened again", "severity": "warning", @@ -2143,7 +2143,7 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@level": "error", "@message": "Error: first error", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "diagnostic": map[string]interface{}{ "detail": "this time it is very bad", "severity": "error", @@ -2278,10 +2278,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... pass", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "pass", }, @@ -2301,10 +2301,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... pass", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "pass", }, @@ -2314,7 +2314,7 @@ func TestTestJSON_Run(t *testing.T) { "@level": "warn", "@message": "Warning: a warning occurred", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "diagnostic": map[string]interface{}{ "detail": "some warning happened during this test", @@ -2333,10 +2333,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... pending", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "pending", }, @@ -2352,10 +2352,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... skip", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "skip", }, @@ -2371,10 +2371,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... fail", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "fail", }, @@ -2397,10 +2397,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... fail", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "fail", }, @@ -2410,7 +2410,7 @@ func TestTestJSON_Run(t *testing.T) { "@level": "error", "@message": "Error: a comparison failed", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "diagnostic": map[string]interface{}{ "detail": "details details details", @@ -2423,7 +2423,7 @@ func TestTestJSON_Run(t *testing.T) { "@level": "error", "@message": "Error: a second comparison failed", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "diagnostic": map[string]interface{}{ "detail": "other details", @@ -2442,10 +2442,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... fail", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "error", }, @@ -2465,10 +2465,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... fail", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "error", }, @@ -2478,7 +2478,7 @@ func TestTestJSON_Run(t *testing.T) { "@level": "error", "@message": "Error: an error occurred", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "diagnostic": map[string]interface{}{ "detail": "something bad happened during this test", @@ -2577,10 +2577,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... pass", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "pass", }, @@ -2590,7 +2590,7 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": "-verbose flag enabled, printing plan", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_plan": map[string]interface{}{ "configuration": map[string]interface{}{ @@ -2701,10 +2701,10 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": " \"run_block\"... pass", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_run": map[string]interface{}{ - "path": "main.tftest", + "path": "main.tftest.hcl", "run": "run_block", "status": "pass", }, @@ -2714,7 +2714,7 @@ func TestTestJSON_Run(t *testing.T) { "@level": "info", "@message": "-verbose flag enabled, printing state", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "@testrun": "run_block", "test_state": map[string]interface{}{ "values": map[string]interface{}{ @@ -2746,7 +2746,7 @@ func TestTestJSON_Run(t *testing.T) { streams, done := terminal.StreamsForTesting(t) view := NewTest(arguments.ViewJSON, NewView(streams)) - file := &moduletest.File{Name: "main.tftest"} + file := &moduletest.File{Name: "main.tftest.hcl"} view.Run(tc.run, file) testJSONViewOutputEquals(t, done(t).All(), tc.want, cmp.FilterPath(func(path cmp.Path) bool { @@ -2801,7 +2801,7 @@ func TestTestJSON_FatalInterruptSummary(t *testing.T) { "@level": "error", "@message": "Terraform was interrupted during test execution, and may not have performed the expected cleanup operations.", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "test_interrupt": map[string]interface{}{ "planned": []interface{}{ "test_instance.one", @@ -2850,7 +2850,7 @@ func TestTestJSON_FatalInterruptSummary(t *testing.T) { "@level": "error", "@message": "Terraform was interrupted during test execution, and may not have performed the expected cleanup operations.", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "test_interrupt": map[string]interface{}{ "state": []interface{}{ map[string]interface{}{ @@ -2903,7 +2903,7 @@ func TestTestJSON_FatalInterruptSummary(t *testing.T) { "@level": "error", "@message": "Terraform was interrupted during test execution, and may not have performed the expected cleanup operations.", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "test_interrupt": map[string]interface{}{ "states": map[string]interface{}{ "setup_block": []interface{}{ @@ -3018,7 +3018,7 @@ func TestTestJSON_FatalInterruptSummary(t *testing.T) { "@level": "error", "@message": "Terraform was interrupted during test execution, and may not have performed the expected cleanup operations.", "@module": "terraform.ui", - "@testfile": "main.tftest", + "@testfile": "main.tftest.hcl", "test_interrupt": map[string]interface{}{ "state": []interface{}{ map[string]interface{}{ @@ -3053,7 +3053,7 @@ func TestTestJSON_FatalInterruptSummary(t *testing.T) { streams, done := terminal.StreamsForTesting(t) view := NewTest(arguments.ViewJSON, NewView(streams)) - file := &moduletest.File{Name: "main.tftest"} + file := &moduletest.File{Name: "main.tftest.hcl"} run := &moduletest.Run{Name: "run_block"} view.FatalInterruptSummary(run, file, tc.states, tc.changes) diff --git a/internal/configs/config_build.go b/internal/configs/config_build.go index 4536fed898..86a184af42 100644 --- a/internal/configs/config_build.go +++ b/internal/configs/config_build.go @@ -57,8 +57,8 @@ func buildTestModules(root *Config, walker ModuleWalker) hcl.Diagnostics { // so we create a dedicated path for them. // // Some examples: - // - file: main.tftest, run: setup - test.main.setup - // - file: tests/main.tftest, run: setup - test.tests.main.setup + // - file: main.tftest.hcl, run: setup - test.main.setup + // - file: tests/main.tftest.hcl, run: setup - test.tests.main.setup dir := path.Dir(name) base := path.Base(name) @@ -68,7 +68,7 @@ func buildTestModules(root *Config, walker ModuleWalker) hcl.Diagnostics { if dir != "." { path = append(path, strings.Split(dir, "/")...) } - path = append(path, strings.TrimSuffix(base, ".tftest"), run.Name) + path = append(path, strings.TrimSuffix(base, ".tftest.hcl"), run.Name) req := ModuleRequest{ Name: run.Name, diff --git a/internal/configs/config_build_test.go b/internal/configs/config_build_test.go index 9ed83df5af..be60f9e3a7 100644 --- a/internal/configs/config_build_test.go +++ b/internal/configs/config_build_test.go @@ -316,7 +316,7 @@ func TestBuildConfig_WithTestModule(t *testing.T) { t.Fatalf("expected exactly one test case but found %d", len(cfg.Module.Tests)) } - test := cfg.Module.Tests["main.tftest"] + test := cfg.Module.Tests["main.tftest.hcl"] if len(test.Runs) != 2 { t.Fatalf("expected two test runs but found %d", len(test.Runs)) } diff --git a/internal/configs/config_test.go b/internal/configs/config_test.go index d9c80df8d6..0bfafce00d 100644 --- a/internal/configs/config_test.go +++ b/internal/configs/config_test.go @@ -383,7 +383,7 @@ func TestConfigProviderRequirementsByModuleInclTests(t *testing.T) { }, Children: make(map[string]*ModuleRequirements), Tests: map[string]*TestFileModuleRequirements{ - "provider-reqs-root.tftest": { + "provider-reqs-root.tftest.hcl": { Requirements: getproviders.Requirements{ configuredProvider: getproviders.MustParseVersionConstraints("~> 1.4"), }, diff --git a/internal/configs/configload/loader_load.go b/internal/configs/configload/loader_load.go index b431e53339..48a507409d 100644 --- a/internal/configs/configload/loader_load.go +++ b/internal/configs/configload/loader_load.go @@ -8,6 +8,7 @@ import ( version "github.com/hashicorp/go-version" "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/terraform/internal/configs" ) @@ -26,7 +27,7 @@ func (l *Loader) LoadConfig(rootDir string) (*configs.Config, hcl.Diagnostics) { } // LoadConfigWithTests matches LoadConfig, except the configs.Config contains -// any relevant .tftest files. +// any relevant .tftest.hcl files. func (l *Loader) LoadConfigWithTests(rootDir string, testDir string) (*configs.Config, hcl.Diagnostics) { return l.loadConfig(l.parser.LoadConfigDirWithTests(rootDir, testDir)) } diff --git a/internal/configs/parser_config_dir.go b/internal/configs/parser_config_dir.go index 97ece4f001..e1fc7ae533 100644 --- a/internal/configs/parser_config_dir.go +++ b/internal/configs/parser_config_dir.go @@ -51,7 +51,7 @@ func (p *Parser) LoadConfigDir(path string) (*Module, hcl.Diagnostics) { } // LoadConfigDirWithTests matches LoadConfigDir, but the return Module also -// contains any relevant .tftest files. +// contains any relevant .tftest.hcl files. func (p *Parser) LoadConfigDirWithTests(path string, testDirectory string) (*Module, hcl.Diagnostics) { primaryPaths, overridePaths, testPaths, diags := p.dirFiles(path, testDirectory) if diags.HasErrors() { @@ -158,7 +158,7 @@ func (p *Parser) dirFiles(dir string, testsDir string) (primary, override, tests continue } - if strings.HasSuffix(testInfo.Name(), ".tftest") || strings.HasSuffix(testInfo.Name(), ".tftest.json") { + if strings.HasSuffix(testInfo.Name(), ".tftest.hcl") || strings.HasSuffix(testInfo.Name(), ".tftest.json") { tests = append(tests, filepath.Join(testsDir, testInfo.Name())) } } @@ -175,7 +175,7 @@ func (p *Parser) dirFiles(dir string, testsDir string) (primary, override, tests continue } - if ext == ".tftest" || ext == ".tftest.json" { + if ext == ".tftest.hcl" || ext == ".tftest.json" { if includeTests { tests = append(tests, filepath.Join(dir, name)) } @@ -229,8 +229,8 @@ func fileExt(path string) string { return ".tf" } else if strings.HasSuffix(path, ".tf.json") { return ".tf.json" - } else if strings.HasSuffix(path, ".tftest") { - return ".tftest" + } else if strings.HasSuffix(path, ".tftest.hcl") { + return ".tftest.hcl" } else if strings.HasSuffix(path, ".tftest.json") { return ".tftest.json" } else { diff --git a/internal/configs/testdata/provider-reqs-with-tests/provider-reqs-root.tftest b/internal/configs/testdata/provider-reqs-with-tests/provider-reqs-root.tftest.hcl similarity index 100% rename from internal/configs/testdata/provider-reqs-with-tests/provider-reqs-root.tftest rename to internal/configs/testdata/provider-reqs-with-tests/provider-reqs-root.tftest.hcl diff --git a/internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_one.tftest b/internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_one.tftest.hcl similarity index 100% rename from internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_one.tftest rename to internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_one.tftest.hcl diff --git a/internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_two.tftest b/internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_two.tftest.hcl similarity index 100% rename from internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_two.tftest rename to internal/configs/testdata/valid-modules/with-tests-expect-failures/test_case_two.tftest.hcl diff --git a/internal/configs/testdata/valid-modules/with-tests-module/main.tftest b/internal/configs/testdata/valid-modules/with-tests-module/main.tftest.hcl similarity index 100% rename from internal/configs/testdata/valid-modules/with-tests-module/main.tftest rename to internal/configs/testdata/valid-modules/with-tests-module/main.tftest.hcl diff --git a/internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_one.tftest b/internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_one.tftest.hcl similarity index 100% rename from internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_one.tftest rename to internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_one.tftest.hcl diff --git a/internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_two.tftest b/internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_two.tftest.hcl similarity index 100% rename from internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_two.tftest rename to internal/configs/testdata/valid-modules/with-tests-nested/tests/test_case_two.tftest.hcl diff --git a/internal/configs/testdata/valid-modules/with-tests/test_case_one.tftest b/internal/configs/testdata/valid-modules/with-tests/test_case_one.tftest.hcl similarity index 100% rename from internal/configs/testdata/valid-modules/with-tests/test_case_one.tftest rename to internal/configs/testdata/valid-modules/with-tests/test_case_one.tftest.hcl diff --git a/internal/configs/testdata/valid-modules/with-tests/test_case_two.tftest b/internal/configs/testdata/valid-modules/with-tests/test_case_two.tftest.hcl similarity index 100% rename from internal/configs/testdata/valid-modules/with-tests/test_case_two.tftest rename to internal/configs/testdata/valid-modules/with-tests/test_case_two.tftest.hcl diff --git a/internal/initwd/module_install_test.go b/internal/initwd/module_install_test.go index 555d04b662..745a18b171 100644 --- a/internal/initwd/module_install_test.go +++ b/internal/initwd/module_install_test.go @@ -743,7 +743,7 @@ func TestModuleInstaller_fromTests(t *testing.T) { config, loadDiags := loader.LoadConfigWithTests(".", "tests") assertNoDiagnostics(t, tfdiags.Diagnostics{}.Append(loadDiags)) - if config.Module.Tests["tests/main.tftest"].Runs[0].ConfigUnderTest == nil { + if config.Module.Tests["tests/main.tftest.hcl"].Runs[0].ConfigUnderTest == nil { t.Fatalf("should have loaded config into the relevant run block but did not") } } @@ -805,7 +805,7 @@ func TestLoadInstallModules_registryFromTest(t *testing.T) { LocalPath: filepath.Join(dir, ".terraform/modules/test.main.setup"), }, - // main.tftest.setup.child_a + // main.tftest.hcl.setup.child_a // (no download because it's a relative path inside acctest_child_a) { Name: "Install", @@ -813,8 +813,8 @@ func TestLoadInstallModules_registryFromTest(t *testing.T) { LocalPath: filepath.Join(dir, ".terraform/modules/test.main.setup/modules/child_a"), }, - // main.tftest.setup.child_a.child_b - // (no download because it's a relative path inside main.tftest.setup.child_a) + // main.tftest.hcl.setup.child_a.child_b + // (no download because it's a relative path inside main.tftest.hcl.setup.child_a) { Name: "Install", ModuleAddr: "test.main.setup.child_a.child_b", @@ -852,7 +852,7 @@ func TestLoadInstallModules_registryFromTest(t *testing.T) { config, loadDiags := loader.LoadConfigWithTests(".", "tests") assertNoDiagnostics(t, tfdiags.Diagnostics{}.Append(loadDiags)) - if config.Module.Tests["main.tftest"].Runs[0].ConfigUnderTest == nil { + if config.Module.Tests["main.tftest.hcl"].Runs[0].ConfigUnderTest == nil { t.Fatalf("should have loaded config into the relevant run block but did not") } } diff --git a/internal/initwd/testdata/local-module-from-test/tests/main.tftest b/internal/initwd/testdata/local-module-from-test/tests/main.tftest.hcl similarity index 100% rename from internal/initwd/testdata/local-module-from-test/tests/main.tftest rename to internal/initwd/testdata/local-module-from-test/tests/main.tftest.hcl diff --git a/internal/initwd/testdata/registry-module-from-test/main.tftest b/internal/initwd/testdata/registry-module-from-test/main.tftest.hcl similarity index 100% rename from internal/initwd/testdata/registry-module-from-test/main.tftest rename to internal/initwd/testdata/registry-module-from-test/main.tftest.hcl diff --git a/internal/terraform/test_context_test.go b/internal/terraform/test_context_test.go index cf6137026b..e8914ea6d5 100644 --- a/internal/terraform/test_context_test.go +++ b/internal/terraform/test_context_test.go @@ -34,7 +34,7 @@ resource "test_resource" "a" { value = "Hello, world!" } `, - "main.tftest": ` + "main.tftest.hcl": ` run "test_case" { assert { condition = test_resource.a.value == "Hello, world!" @@ -90,7 +90,7 @@ resource "test_resource" "a" { value = var.value } `, - "main.tftest": ` + "main.tftest.hcl": ` variables { value = "Hello, world!" } @@ -151,7 +151,7 @@ resource "test_resource" "a" { value = "Hello, world!" } `, - "main.tftest": ` + "main.tftest.hcl": ` run "test_case" { assert { condition = test_resource.a.value == "incorrect!" @@ -213,7 +213,7 @@ run "test_case" { }) run := moduletest.Run{ - Config: config.Module.Tests["main.tftest"].Runs[0], + Config: config.Module.Tests["main.tftest.hcl"].Runs[0], Name: "test_case", } @@ -247,7 +247,7 @@ resource "test_resource" "a" { value = "Hello, world!" } `, - "main.tftest": ` + "main.tftest.hcl": ` run "test_case" { assert { condition = test_resource.a.value == "Hello, world!" @@ -323,7 +323,7 @@ resource "test_resource" "a" { value = "Hello, world!" } `, - "main.tftest": ` + "main.tftest.hcl": ` run "test_case" { assert { condition = test_resource.a.value == "incorrect!" @@ -409,7 +409,7 @@ run "test_case" { }) run := moduletest.Run{ - Config: config.Module.Tests["main.tftest"].Runs[0], + Config: config.Module.Tests["main.tftest.hcl"].Runs[0], Name: "test_case", }