From 2ee46eda9482a1555dd946fda089a657c2d04dc3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 17 Jul 2015 10:58:47 -0700 Subject: [PATCH] test case --- terraform/context_apply_test.go | 37 +++++++++++++++++++ .../child/main.tf | 3 ++ .../child/subchild/main.tf | 1 + .../main.tf | 3 ++ 4 files changed, 44 insertions(+) create mode 100644 terraform/test-fixtures/apply-module-provider-close-nested/child/main.tf create mode 100644 terraform/test-fixtures/apply-module-provider-close-nested/child/subchild/main.tf create mode 100644 terraform/test-fixtures/apply-module-provider-close-nested/main.tf diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 032310aac..2f4d43296 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -894,6 +894,43 @@ func TestContext2Apply_moduleProviderAliasTargets(t *testing.T) { } } +func TestContext2Apply_moduleProviderCloseNested(t *testing.T) { + m := testModule(t, "apply-module-provider-close-nested") + p := testProvider("aws") + p.ApplyFn = testApplyFn + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + State: &State{ + Modules: []*ModuleState{ + &ModuleState{ + Path: []string{"root", "child", "subchild"}, + Resources: map[string]*ResourceState{ + "aws_instance.foo": &ResourceState{ + Type: "aws_instance", + Primary: &InstanceState{ + ID: "bar", + }, + }, + }, + }, + }, + }, + Destroy: true, + }) + + if _, err := ctx.Plan(); err != nil { + t.Fatalf("err: %s", err) + } + + if _, err := ctx.Apply(); err != nil { + t.Fatalf("err: %s", err) + } +} + func TestContext2Apply_moduleVarResourceCount(t *testing.T) { m := testModule(t, "apply-module-var-resource-count") p := testProvider("aws") diff --git a/terraform/test-fixtures/apply-module-provider-close-nested/child/main.tf b/terraform/test-fixtures/apply-module-provider-close-nested/child/main.tf new file mode 100644 index 000000000..852bce8b9 --- /dev/null +++ b/terraform/test-fixtures/apply-module-provider-close-nested/child/main.tf @@ -0,0 +1,3 @@ +module "subchild" { + source = "./subchild" +} diff --git a/terraform/test-fixtures/apply-module-provider-close-nested/child/subchild/main.tf b/terraform/test-fixtures/apply-module-provider-close-nested/child/subchild/main.tf new file mode 100644 index 000000000..919f140bb --- /dev/null +++ b/terraform/test-fixtures/apply-module-provider-close-nested/child/subchild/main.tf @@ -0,0 +1 @@ +resource "aws_instance" "foo" {} diff --git a/terraform/test-fixtures/apply-module-provider-close-nested/main.tf b/terraform/test-fixtures/apply-module-provider-close-nested/main.tf new file mode 100644 index 000000000..0f6991c53 --- /dev/null +++ b/terraform/test-fixtures/apply-module-provider-close-nested/main.tf @@ -0,0 +1,3 @@ +module "child" { + source = "./child" +}