From 56a34087babd6ef2186a8c54ebe030ab86c52a08 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 24 Nov 2014 15:42:58 -0800 Subject: [PATCH] terraform: test orphan dependency inversion --- terraform/graph_test.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/terraform/graph_test.go b/terraform/graph_test.go index d7b464ffec..4f87e245be 100644 --- a/terraform/graph_test.go +++ b/terraform/graph_test.go @@ -754,8 +754,27 @@ func TestGraphAddDiff_module_depends(t *testing.T) { }, }, } + state := &State{ + Modules: []*ModuleState{ + &ModuleState{ + Path: []string{"root", "orphan"}, + Resources: map[string]*ResourceState{ + "aws_instance.dead": &ResourceState{ + Type: "aws_instance", + Primary: &InstanceState{ + ID: "dead", + }, + }, + }, + Dependencies: []string{ + "aws_instance.foo", + "module.child", + }, + }, + }, + } - g, err := Graph(&GraphOpts{Module: m, Diff: diff}) + g, err := Graph(&GraphOpts{Module: m, Diff: diff, State: state}) if err != nil { t.Fatalf("err: %s", err) } @@ -1316,10 +1335,14 @@ aws_instance.foo aws_instance.foo -> aws_instance.foo (destroy) aws_instance.foo (destroy) aws_instance.foo (destroy) -> module.child + aws_instance.foo (destroy) -> module.orphan module.child + module.child -> module.orphan +module.orphan root root -> aws_instance.foo root -> module.child + root -> module.orphan ` const testTerraformGraphModulesStr = `