From f39a5d096235f4c21c81ae6b9037904080e9a4d8 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 13 Nov 2018 17:39:06 -0800 Subject: [PATCH] command: Fix various TestMetaBackend-prefix tests Our new state model has a different implementation of "empty" that doesn't consider lineage/serial, so we need to have some actual content in these state fixtures to avoid them being skipped during state migrations. --- command/meta_backend_test.go | 8 ++++---- .../local-state.tfstate | 14 +++++++++++++- .../local-state.tfstate | 14 +++++++++++++- .../terraform.tfstate.d/env2/terraform.tfstate | 14 +++++++++++++- .../local-state.tfstate | 14 +++++++++++++- .../terraform.tfstate.d/env2/terraform.tfstate | 14 +++++++++++++- .../terraform.tfstate.d/env2/terraform.tfstate | 14 +++++++++++++- .../terraform.tfstate.d/env1/terraform.tfstate | 14 +++++++++++++- .../terraform.tfstate.d/env2/terraform.tfstate | 14 +++++++++++++- .../local-state.tfstate | 14 +++++++++++++- .../backend-change/local-state.tfstate | 14 +++++++++++++- .../backend-new-migrate-existing/terraform.tfstate | 7 ++++++- .../backend-unset/local-state.tfstate | 14 +++++++++++++- 13 files changed, 153 insertions(+), 16 deletions(-) diff --git a/command/meta_backend_test.go b/command/meta_backend_test.go index f0c951094..09ffccb76 100644 --- a/command/meta_backend_test.go +++ b/command/meta_backend_test.go @@ -502,8 +502,8 @@ func TestMetaBackend_configureNewWithStateExisting(t *testing.T) { if state == nil { t.Fatal("state is nil") } - if testStateMgrCurrentLineage(s) != "local" { - t.Fatalf("bad: %#v", state) + if got, want := testStateMgrCurrentLineage(s), "local"; got != want { + t.Fatalf("wrong lineage %q; want %q", got, want) } // Write some state @@ -1414,8 +1414,8 @@ func TestMetaBackend_configuredUnsetCopy(t *testing.T) { if state == nil { t.Fatal("state is nil") } - if testStateMgrCurrentLineage(s) != "configuredUnset" { - t.Fatalf("bad: %#v", state) + if got, want := testStateMgrCurrentLineage(s), "configuredUnset"; got != want { + t.Fatalf("wrong state lineage %q; want %q", got, want) } // Verify a backup doesn't exist diff --git a/command/test-fixtures/backend-change-multi-default-to-single/local-state.tfstate b/command/test-fixtures/backend-change-multi-default-to-single/local-state.tfstate index 88c1d86ec..c30143790 100644 --- a/command/test-fixtures/backend-change-multi-default-to-single/local-state.tfstate +++ b/command/test-fixtures/backend-change-multi-default-to-single/local-state.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change" + "lineage": "backend-change", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-multi-to-multi/local-state.tfstate b/command/test-fixtures/backend-change-multi-to-multi/local-state.tfstate index 88c1d86ec..c30143790 100644 --- a/command/test-fixtures/backend-change-multi-to-multi/local-state.tfstate +++ b/command/test-fixtures/backend-change-multi-to-multi/local-state.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change" + "lineage": "backend-change", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-multi-to-multi/terraform.tfstate.d/env2/terraform.tfstate b/command/test-fixtures/backend-change-multi-to-multi/terraform.tfstate.d/env2/terraform.tfstate index 855a27f4c..83854e0f6 100644 --- a/command/test-fixtures/backend-change-multi-to-multi/terraform.tfstate.d/env2/terraform.tfstate +++ b/command/test-fixtures/backend-change-multi-to-multi/terraform.tfstate.d/env2/terraform.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change-env2" + "lineage": "backend-change-env2", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-multi-to-no-default-with-default/local-state.tfstate b/command/test-fixtures/backend-change-multi-to-no-default-with-default/local-state.tfstate index 980f732f6..18ae42c9a 100644 --- a/command/test-fixtures/backend-change-multi-to-no-default-with-default/local-state.tfstate +++ b/command/test-fixtures/backend-change-multi-to-no-default-with-default/local-state.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change-env1" + "lineage": "backend-change-env1", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-multi-to-no-default-with-default/terraform.tfstate.d/env2/terraform.tfstate b/command/test-fixtures/backend-change-multi-to-no-default-with-default/terraform.tfstate.d/env2/terraform.tfstate index 855a27f4c..83854e0f6 100644 --- a/command/test-fixtures/backend-change-multi-to-no-default-with-default/terraform.tfstate.d/env2/terraform.tfstate +++ b/command/test-fixtures/backend-change-multi-to-no-default-with-default/terraform.tfstate.d/env2/terraform.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change-env2" + "lineage": "backend-change-env2", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-multi-to-no-default-without-default/terraform.tfstate.d/env2/terraform.tfstate b/command/test-fixtures/backend-change-multi-to-no-default-without-default/terraform.tfstate.d/env2/terraform.tfstate index 855a27f4c..83854e0f6 100644 --- a/command/test-fixtures/backend-change-multi-to-no-default-without-default/terraform.tfstate.d/env2/terraform.tfstate +++ b/command/test-fixtures/backend-change-multi-to-no-default-without-default/terraform.tfstate.d/env2/terraform.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change-env2" + "lineage": "backend-change-env2", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env1/terraform.tfstate b/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env1/terraform.tfstate index 88c1d86ec..c30143790 100644 --- a/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env1/terraform.tfstate +++ b/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env1/terraform.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change" + "lineage": "backend-change", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env2/terraform.tfstate b/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env2/terraform.tfstate index 855a27f4c..83854e0f6 100644 --- a/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env2/terraform.tfstate +++ b/command/test-fixtures/backend-change-multi-to-single/terraform.tfstate.d/env2/terraform.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change-env2" + "lineage": "backend-change-env2", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change-single-to-single/local-state.tfstate b/command/test-fixtures/backend-change-single-to-single/local-state.tfstate index 88c1d86ec..c30143790 100644 --- a/command/test-fixtures/backend-change-single-to-single/local-state.tfstate +++ b/command/test-fixtures/backend-change-single-to-single/local-state.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change" + "lineage": "backend-change", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-change/local-state.tfstate b/command/test-fixtures/backend-change/local-state.tfstate index 88c1d86ec..c30143790 100644 --- a/command/test-fixtures/backend-change/local-state.tfstate +++ b/command/test-fixtures/backend-change/local-state.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "backend-change" + "lineage": "backend-change", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] } diff --git a/command/test-fixtures/backend-new-migrate-existing/terraform.tfstate b/command/test-fixtures/backend-new-migrate-existing/terraform.tfstate index 7fc619980..ce8d954f4 100644 --- a/command/test-fixtures/backend-new-migrate-existing/terraform.tfstate +++ b/command/test-fixtures/backend-new-migrate-existing/terraform.tfstate @@ -8,7 +8,12 @@ "path": [ "root" ], - "outputs": {}, + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, "resources": {}, "depends_on": [] } diff --git a/command/test-fixtures/backend-unset/local-state.tfstate b/command/test-fixtures/backend-unset/local-state.tfstate index 51d588030..35caa2dc6 100644 --- a/command/test-fixtures/backend-unset/local-state.tfstate +++ b/command/test-fixtures/backend-unset/local-state.tfstate @@ -2,5 +2,17 @@ "version": 3, "terraform_version": "0.8.2", "serial": 7, - "lineage": "configuredUnset" + "lineage": "configuredUnset", + "modules": [ + { + "path": ["root"], + "outputs": { + "foo": { + "type": "string", + "value": "bar" + } + }, + "resources": {} + } + ] }