@ -831,6 +831,30 @@ main.tftest.hcl/run_block.
Error : first error
this time it is very bad
` ,
} ,
"state_with_skip_cleanup" : {
run : & moduletest . Run { Name : "run_block" , Config : & configs . TestRun { SkipCleanup : true } } ,
file : & moduletest . File { Name : "main.tftest.hcl" } ,
state : states . BuildState ( func ( state * states . SyncState ) {
state . SetResourceInstanceCurrent (
addrs . Resource {
Mode : addrs . ManagedResourceMode ,
Type : "test" ,
Name : "foo" ,
} . Instance ( addrs . NoKey ) . Absolute ( addrs . RootModuleInstance ) ,
& states . ResourceInstanceObjectSrc {
Status : states . ObjectReady ,
} ,
addrs . AbsProviderConfig {
Module : addrs . RootModule ,
Provider : addrs . NewDefaultProvider ( "test" ) ,
} )
} ) ,
stdout : `
Terraform left the following resources in state after executing
main . tftest . hcl / run_block because the skip_cleanup attribute was set :
- test . foo
` ,
} ,
"state_only_warnings" : {
@ -1982,6 +2006,42 @@ func TestTestJSON_DestroySummary(t *testing.T) {
} ,
} ,
} ,
"state_from_run_skip_cleanup" : {
file : & moduletest . File { Name : "main.tftest.hcl" } ,
run : & moduletest . Run { Name : "run_block" , Config : & configs . TestRun { SkipCleanup : true } } ,
state : states . BuildState ( func ( state * states . SyncState ) {
state . SetResourceInstanceCurrent (
addrs . Resource {
Mode : addrs . ManagedResourceMode ,
Type : "test" ,
Name : "foo" ,
} . Instance ( addrs . NoKey ) . Absolute ( addrs . RootModuleInstance ) ,
& states . ResourceInstanceObjectSrc {
Status : states . ObjectReady ,
} ,
addrs . AbsProviderConfig {
Module : addrs . RootModule ,
Provider : addrs . NewDefaultProvider ( "test" ) ,
} )
} ) ,
want : [ ] map [ string ] interface { } {
{
"@level" : "info" ,
"@message" : "Terraform left some resources in state after executing main.tftest.hcl/run_block because the skip_cleanup attribute was set." ,
"@module" : "terraform.ui" ,
"@testfile" : "main.tftest.hcl" ,
"@testrun" : "run_block" ,
"test_cleanup_skipped" : map [ string ] interface { } {
"resources" : [ ] interface { } {
map [ string ] interface { } {
"instance" : "test.foo" ,
} ,
} ,
} ,
"type" : "test_cleanup_skipped" ,
} ,
} ,
} ,
"state_only_warnings" : {
diags : tfdiags . Diagnostics {
tfdiags . Sourceless ( tfdiags . Warning , "first warning" , "something not very bad happened" ) ,