|
|
|
|
@ -154,6 +154,49 @@ func TestBuiltinGraphBuilder_multiLevelModule(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuiltinGraphBuilder_orphanDeps(t *testing.T) {
|
|
|
|
|
state := &State{
|
|
|
|
|
Modules: []*ModuleState{
|
|
|
|
|
&ModuleState{
|
|
|
|
|
Path: rootModulePath,
|
|
|
|
|
Resources: map[string]*ResourceState{
|
|
|
|
|
"aws_instance.foo": &ResourceState{
|
|
|
|
|
Type: "aws_instance",
|
|
|
|
|
Primary: &InstanceState{
|
|
|
|
|
ID: "foo",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"aws_instance.bar": &ResourceState{
|
|
|
|
|
Type: "aws_instance",
|
|
|
|
|
Dependencies: []string{"aws_instance.foo"},
|
|
|
|
|
Primary: &InstanceState{
|
|
|
|
|
ID: "bar",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b := &BuiltinGraphBuilder{
|
|
|
|
|
Root: testModule(t, "graph-builder-orphan-deps"),
|
|
|
|
|
State: state,
|
|
|
|
|
Validate: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g, err := b.Build(RootModulePath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
actual := strings.TrimSpace(g.String())
|
|
|
|
|
expected := strings.TrimSpace(testBuiltinGraphBuilderOrphanDepsStr)
|
|
|
|
|
if actual != expected {
|
|
|
|
|
t.Fatalf("bad: %s", actual)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
TODO: This exposes a really bad bug we need to fix after we merge
|
|
|
|
|
the f-ast-branch. This bug still exists in master.
|
|
|
|
|
@ -233,6 +276,16 @@ root
|
|
|
|
|
module.foo.plan-destroy
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testBuiltinGraphBuilderOrphanDepsStr = `
|
|
|
|
|
aws_instance.bar (orphan)
|
|
|
|
|
provider.aws
|
|
|
|
|
aws_instance.foo (orphan)
|
|
|
|
|
aws_instance.bar (orphan)
|
|
|
|
|
provider.aws
|
|
|
|
|
provider.aws (close)
|
|
|
|
|
aws_instance.foo (orphan)
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
TODO: Commented out this const as it's likely this needs to
|
|
|
|
|
be updated when the TestBuiltinGraphBuilder_modules test is
|
|
|
|
|
|