From e54949f2e1cbd62d0401f7d2b7b7d2f34735cbfc Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 11 Sep 2020 15:53:21 -0400 Subject: [PATCH] fix show -json tests The prior state recorded in the plans did not match the actual prior state. Make the plans and state match depending on whether there was existing state or not. --- command/testdata/show-json/basic-create/output.json | 13 +------------ .../show-json/basic-delete/terraform.tfstate | 7 ++++++- .../show-json/basic-update/terraform.tfstate | 7 ++++++- command/testdata/show-json/modules/output.json | 13 +------------ .../show-json/multi-resource-update/output.json | 8 +------- 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/command/testdata/show-json/basic-create/output.json b/command/testdata/show-json/basic-create/output.json index ff83de3fef..19e1846cc9 100644 --- a/command/testdata/show-json/basic-create/output.json +++ b/command/testdata/show-json/basic-create/output.json @@ -53,18 +53,7 @@ ] } }, - "prior_state": { - "format_version": "0.1", - "values": { - "outputs": { - "test": { - "sensitive": false, - "value": "bar" - } - }, - "root_module": {} - } - }, + "prior_state": {}, "resource_changes": [ { "address": "test_instance.test[0]", diff --git a/command/testdata/show-json/basic-delete/terraform.tfstate b/command/testdata/show-json/basic-delete/terraform.tfstate index ac865b8644..6d2b622377 100644 --- a/command/testdata/show-json/basic-delete/terraform.tfstate +++ b/command/testdata/show-json/basic-delete/terraform.tfstate @@ -3,7 +3,12 @@ "terraform_version": "0.12.0", "serial": 7, "lineage": "configuredUnchanged", - "outputs": {}, + "outputs": { + "test": { + "value": "bar", + "type": "string" + } + }, "resources": [ { "mode": "managed", diff --git a/command/testdata/show-json/basic-update/terraform.tfstate b/command/testdata/show-json/basic-update/terraform.tfstate index b57f60f843..bc691aee08 100644 --- a/command/testdata/show-json/basic-update/terraform.tfstate +++ b/command/testdata/show-json/basic-update/terraform.tfstate @@ -3,7 +3,12 @@ "terraform_version": "0.12.0", "serial": 7, "lineage": "configuredUnchanged", - "outputs": {}, + "outputs": { + "test": { + "value": "bar", + "type": "string" + } + }, "resources": [ { "mode": "managed", diff --git a/command/testdata/show-json/modules/output.json b/command/testdata/show-json/modules/output.json index 898763aad9..76b4f471ca 100644 --- a/command/testdata/show-json/modules/output.json +++ b/command/testdata/show-json/modules/output.json @@ -69,18 +69,7 @@ ] } }, - "prior_state": { - "format_version": "0.1", - "values": { - "outputs": { - "test": { - "sensitive": false, - "value": "baz" - } - }, - "root_module": {} - } - }, + "prior_state": {}, "resource_changes": [ { "address": "module.module_test_bar.test_instance.test", diff --git a/command/testdata/show-json/multi-resource-update/output.json b/command/testdata/show-json/multi-resource-update/output.json index cc8f6d1ede..ba764b2651 100644 --- a/command/testdata/show-json/multi-resource-update/output.json +++ b/command/testdata/show-json/multi-resource-update/output.json @@ -101,20 +101,14 @@ "format_version": "0.1", "terraform_version": "0.13.0", "values": { - "outputs": { - "test": { - "sensitive": false, - "value": "bar" - } - }, "root_module": { "resources": [ { "address": "test_instance.test[0]", + "index": 0, "mode": "managed", "type": "test_instance", "name": "test", - "index": 0, "provider_name": "registry.terraform.io/hashicorp/test", "schema_version": 0, "values": {