From 687830a5d59ad9b14832a13f188a7b5dd6417a71 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 25 May 2018 15:42:33 -0700 Subject: [PATCH] core: Mock schema for TestContext2Apply_multiProviderDestroy This test seems to have been buggy before our current work, with the test fixture containing a reference to a resource that doesn't exist. This both fixes the fixture and adds a mock schema for it, though this just revealed another error which isn't fixed here, where the a_ids value seems to come through as unknown after apply. That will be fixed in a subsequent commit. --- terraform/context_apply_test.go | 12 +++++++++++- .../apply-multi-var-missing-state/child/child.tf | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 3fe2b11dd..48289957a 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -3250,7 +3250,7 @@ func TestContext2Apply_multiProviderDestroy(t *testing.T) { ResourceTypes: map[string]*configschema.Block{ "vault_instance": { Attributes: map[string]*configschema.Attribute{ - "id": {Type: cty.String, Computed: true}, + "id": {Type: cty.String, Computed: true}, }, }, }, @@ -3900,6 +3900,16 @@ func TestContext2Apply_multiVarMissingState(t *testing.T) { p := testProvider("test") p.ApplyFn = testApplyFn p.DiffFn = testDiffFn + p.GetSchemaReturn = &ProviderSchema{ + ResourceTypes: map[string]*configschema.Block{ + "test_thing": { + Attributes: map[string]*configschema.Attribute{ + "a_ids": {Type: cty.String, Optional: true}, + "id": {Type: cty.String, Computed: true}, + }, + }, + }, + } // First, apply with a count of 3 ctx := testContext2(t, &ContextOpts{ diff --git a/terraform/test-fixtures/apply-multi-var-missing-state/child/child.tf b/terraform/test-fixtures/apply-multi-var-missing-state/child/child.tf index 928018627..b5df05d0e 100644 --- a/terraform/test-fixtures/apply-multi-var-missing-state/child/child.tf +++ b/terraform/test-fixtures/apply-multi-var-missing-state/child/child.tf @@ -11,5 +11,5 @@ resource "test_thing" "a" { # over all of the resource in the state. This should succeed even though the # module state will be nil when evaluating the variable. resource "test_thing" "b" { - a_ids = "${join(" ", null_resource.a.*.id)}" + a_ids = "${join(" ", test_thing.a.*.id)}" }