From f7bed9a2f918949188b267a68372733f2ed814f1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 11 Feb 2015 17:18:16 -0800 Subject: [PATCH] terraform: more tests --- terraform/context_test.go | 2 +- terraform/transform_resource.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/terraform/context_test.go b/terraform/context_test.go index 70c5b2b6c..cf25714a0 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -181,7 +181,6 @@ func TestContext2Plan_moduleInputFromVar(t *testing.T) { } } -/* func TestContext2Plan_moduleMultiVar(t *testing.T) { m := testModule(t, "plan-module-multi-var") p := testProvider("aws") @@ -205,6 +204,7 @@ func TestContext2Plan_moduleMultiVar(t *testing.T) { } } +/* func TestContextPlan_moduleOrphans(t *testing.T) { m := testModule(t, "plan-modules-remove") p := testProvider("aws") diff --git a/terraform/transform_resource.go b/terraform/transform_resource.go index c205e17c1..c8dfec12e 100644 --- a/terraform/transform_resource.go +++ b/terraform/transform_resource.go @@ -28,9 +28,16 @@ func (t *ResourceCountTransformer) Transform(g *Graph) error { // For each count, build and add the node nodes := make([]dag.Vertex, count) for i := 0; i < count; i++ { + // Set the index. If our count is 1 we special case it so that + // we handle the "resource.0" and "resource" boundary properly. + index := i + if count == 1 { + index = -1 + } + // Save the node for later so we can do connections nodes[i] = &graphNodeExpandedResource{ - Index: i, + Index: index, Resource: t.Resource, } @@ -146,7 +153,7 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode { // stateId is the name used for the state key func (n *graphNodeExpandedResource) stateId() string { - if n.Index == 0 { + if n.Index == -1 { return n.Resource.Id() }