From 8219912d1be698470817c2a522b7df693f098561 Mon Sep 17 00:00:00 2001 From: UKEME BASSEY Date: Mon, 27 Apr 2026 11:51:12 -0400 Subject: [PATCH] add changelog & updates --- .../v1.16/ENHANCEMENTS-20260427-112604.yaml | 5 +++++ internal/command/test_test.go | 21 +++++++++++++++++-- internal/command/views/test_test.go | 6 +++--- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 .changes/v1.16/ENHANCEMENTS-20260427-112604.yaml diff --git a/.changes/v1.16/ENHANCEMENTS-20260427-112604.yaml b/.changes/v1.16/ENHANCEMENTS-20260427-112604.yaml new file mode 100644 index 0000000000..9ac840f55e --- /dev/null +++ b/.changes/v1.16/ENHANCEMENTS-20260427-112604.yaml @@ -0,0 +1,5 @@ +kind: ENHANCEMENTS +body: Show info when resources are left behind due to skip_cleanup +time: 2026-04-27T11:26:04.782451-04:00 +custom: + Issue: "38449" diff --git a/internal/command/test_test.go b/internal/command/test_test.go index 5844020059..d3dd717a73 100644 --- a/internal/command/test_test.go +++ b/internal/command/test_test.go @@ -813,6 +813,10 @@ func TestTest_Cleanup(t *testing.T) { run "test_three"... pass run "test_four"... pass main.tftest.hcl... tearing down + +Terraform left the following resources in state after executing +main.tftest.hcl/test_two because the skip_cleanup attribute was set: + - test_resource.resource main.tftest.hcl... fail Failure! 4 passed, 0 failed. @@ -948,6 +952,10 @@ Success! expectedCleanup := `main.tftest.hcl... in progress main.tftest.hcl... tearing down + +Terraform left the following resources in state after executing +main.tftest.hcl/test_two because the skip_cleanup attribute was set: + - test_resource.resource main.tftest.hcl... pass Success! @@ -3273,9 +3281,10 @@ main.tftest.hcl... in progress run "test_four"... pass run "test_five"... pass main.tftest.hcl... tearing down + Terraform left the following resources in state after executing main.tftest.hcl/test_three because the skip_cleanup attribute was set: - - test_resource.resource + - test_resource.resource main.tftest.hcl... pass Success! 5 passed, 0 failed. @@ -3365,6 +3374,10 @@ func TestTest_SkipCleanupWithRunDependencies(t *testing.T) { run "test_two"... pass run "test_three"... pass main.tftest.hcl... tearing down + +Terraform left the following resources in state after executing +main.tftest.hcl/test_two because the skip_cleanup attribute was set: + - test_resource.resource main.tftest.hcl... pass Success! 3 passed, 0 failed. @@ -3546,7 +3559,7 @@ func TestTest_SkipCleanup_JSON(t *testing.T) { `{"@level":"info","@message":" \"test_five\"... pass","@module":"terraform.ui","@testfile":"main.tftest.hcl","@testrun":"test_five","test_run":{"path":"main.tftest.hcl","progress":"complete","run":"test_five","status":"pass"},"type":"test_run"}`, `{"@level":"info","@message":"main.tftest.hcl... tearing down","@module":"terraform.ui","@testfile":"main.tftest.hcl","test_file":{"path":"main.tftest.hcl","progress":"teardown"},"type":"test_file"}`, `{"@level":"info","@message":" \"test_three\"... tearing down","@module":"terraform.ui","@testfile":"main.tftest.hcl","@testrun":"test_three","test_run":{"path":"main.tftest.hcl","progress":"teardown","run":"test_three"},"type":"test_run"}`, - `{"@level":"info","@message":"Terraform left some resources in state after executing main.tftest.hcl/test_three because the skip_cleanup attribute was set.","@module":"terraform.ui","@testfile":"main.tftest.hcl","@testrun":"test_three","test_cleanup_skipped":{"resources":[{"instance":"test_resource.resource"}]},"type":"test_cleanup_skipped"}`, + `{"@level":"info","@message":"Terraform left some resources in state after executing main.tftest.hcl/test_three because the skip_cleanup attribute was set.","@module":"terraform.ui","@testfile":"main.tftest.hcl","@testrun":"test_three","test_cleanup":{"skipped_resources":[{"instance":"test_resource.resource"}]},"type":"test_cleanup"}`, `{"@level":"info","@message":"main.tftest.hcl... pass","@module":"terraform.ui","@testfile":"main.tftest.hcl","test_file":{"path":"main.tftest.hcl","progress":"complete","status":"pass"},"type":"test_file"}`, `{"@level":"info","@message":"Success! 5 passed, 0 failed.","@module":"terraform.ui","test_summary":{"errored":0,"failed":0,"passed":5,"skipped":0,"status":"pass"},"type":"test_summary"}`, } @@ -3627,6 +3640,10 @@ func TestTest_SkipCleanup_FileLevelFlag(t *testing.T) { run "test_four"... pass run "test_five"... pass main.tftest.hcl... tearing down + +Terraform left the following resources in state after executing +main.tftest.hcl/test_four because the skip_cleanup attribute was set: + - test_resource.resource main.tftest.hcl... pass Success! 5 passed, 0 failed. diff --git a/internal/command/views/test_test.go b/internal/command/views/test_test.go index 563332a2a1..0c4cd24749 100644 --- a/internal/command/views/test_test.go +++ b/internal/command/views/test_test.go @@ -2031,14 +2031,14 @@ func TestTestJSON_DestroySummary(t *testing.T) { "@module": "terraform.ui", "@testfile": "main.tftest.hcl", "@testrun": "run_block", - "test_cleanup_skipped": map[string]interface{}{ - "resources": []interface{}{ + "test_cleanup": map[string]interface{}{ + "skipped_resources": []interface{}{ map[string]interface{}{ "instance": "test.foo", }, }, }, - "type": "test_cleanup_skipped", + "type": "test_cleanup", }, }, },