From 0039d3dbf3517f9fd84332ec38cf2e9ab52d2ed2 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 12 Sep 2018 11:29:02 -0700 Subject: [PATCH] core: Remove uses of InstanceInfo.HumanId in context apply tests This method is now removed, because our shims to the old provider API (which used InstanceInfo) now populate only the Type attribute and so HumanId would just generate garbage results anyway. --- terraform/context_apply_test.go | 19 +++++++++---------- .../apply-multi-var-count-dec/main.tf | 8 +++++--- .../child/child/main.tf | 4 +++- .../main.tf | 6 ++++-- .../child/child/main.tf | 4 +++- .../child/main.tf | 5 +++-- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 2e46caa5e..ba0e98694 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -407,7 +407,8 @@ func TestContext2Apply_resourceDependsOnModuleDestroy(t *testing.T) { info *InstanceInfo, is *InstanceState, id *InstanceDiff) (*InstanceState, error) { - if info.HumanId() == "aws_instance.a" { + + if id.Attributes["ami"].New == "parent" { checked = true // Sleep to allow parallel execution @@ -469,7 +470,8 @@ func TestContext2Apply_resourceDependsOnModuleGrandchild(t *testing.T) { info *InstanceInfo, is *InstanceState, id *InstanceDiff) (*InstanceState, error) { - if info.HumanId() == "module.child.module.grandchild.aws_instance.c" { + + if id.Attributes["ami"].New == "grandchild" { checked = true // Sleep to allow parallel execution @@ -521,11 +523,8 @@ func TestContext2Apply_resourceDependsOnModuleInModule(t *testing.T) { // called a child. var called int32 var checked bool - p.ApplyFn = func( - info *InstanceInfo, - is *InstanceState, - id *InstanceDiff) (*InstanceState, error) { - if info.HumanId() == "module.child.module.grandchild.aws_instance.c" { + p.ApplyFn = func(info *InstanceInfo, is *InstanceState, id *InstanceDiff) (*InstanceState, error) { + if id.Attributes["ami"].New == "child" { checked = true // Sleep to allow parallel execution @@ -3259,7 +3258,7 @@ func TestContext2Apply_multiProviderDestroy(t *testing.T) { lock.Lock() defer lock.Unlock() - if info.HumanId() == "aws_instance.bar" { + if info.Type == "aws_instance" { checked = true // Sleep to allow parallel execution @@ -3386,7 +3385,7 @@ func TestContext2Apply_multiProviderDestroyChild(t *testing.T) { lock.Lock() defer lock.Unlock() - if info.HumanId() == "module.child.aws_instance.bar" { + if info.Type == "aws_instance" { checked = true // Sleep to allow parallel execution @@ -3859,7 +3858,7 @@ func TestContext2Apply_multiVarCountDec(t *testing.T) { lock.Lock() defer lock.Unlock() - if info.HumanId() == "aws_instance.bar" { + if id.Attributes["ami"].New == "special" { checked = true // Sleep to allow parallel execution diff --git a/terraform/test-fixtures/apply-multi-var-count-dec/main.tf b/terraform/test-fixtures/apply-multi-var-count-dec/main.tf index c69ec500b..40476512f 100644 --- a/terraform/test-fixtures/apply-multi-var-count-dec/main.tf +++ b/terraform/test-fixtures/apply-multi-var-count-dec/main.tf @@ -1,10 +1,12 @@ variable "num" {} resource "aws_instance" "foo" { - count = "${var.num}" - value = "foo" + count = "${var.num}" + value = "foo" } resource "aws_instance" "bar" { - value = "${join(",", aws_instance.foo.*.id)}" + ami = "special" + + value = "${join(",", aws_instance.foo.*.id)}" } diff --git a/terraform/test-fixtures/apply-resource-depends-on-module-deep/child/child/main.tf b/terraform/test-fixtures/apply-resource-depends-on-module-deep/child/child/main.tf index 716e64b1a..77203263d 100644 --- a/terraform/test-fixtures/apply-resource-depends-on-module-deep/child/child/main.tf +++ b/terraform/test-fixtures/apply-resource-depends-on-module-deep/child/child/main.tf @@ -1 +1,3 @@ -resource "aws_instance" "c" {} +resource "aws_instance" "c" { + ami = "grandchild" +} diff --git a/terraform/test-fixtures/apply-resource-depends-on-module-deep/main.tf b/terraform/test-fixtures/apply-resource-depends-on-module-deep/main.tf index a0859c0fd..1a7862b0a 100644 --- a/terraform/test-fixtures/apply-resource-depends-on-module-deep/main.tf +++ b/terraform/test-fixtures/apply-resource-depends-on-module-deep/main.tf @@ -1,7 +1,9 @@ module "child" { - source = "./child" + source = "./child" } resource "aws_instance" "a" { - depends_on = ["module.child"] + ami = "parent" + + depends_on = ["module.child"] } diff --git a/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/child/main.tf b/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/child/main.tf index 3794f75c0..28d867a3d 100644 --- a/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/child/main.tf +++ b/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/child/main.tf @@ -1,2 +1,4 @@ -resource "aws_instance" "c" {} +resource "aws_instance" "c" { + ami = "grandchild" +} diff --git a/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/main.tf b/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/main.tf index 62fb42cfd..a816cae90 100644 --- a/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/main.tf +++ b/terraform/test-fixtures/apply-resource-depends-on-module-in-module/child/main.tf @@ -1,7 +1,8 @@ module "grandchild" { - source = "./child" + source = "./child" } resource "aws_instance" "b" { - depends_on = ["module.grandchild"] + ami = "child" + depends_on = ["module.grandchild"] }