Add failing test for destroy with locals

This commit is contained in:
James Bardin 2017-09-28 11:06:37 -04:00
parent a28b5d295e
commit 9d8ab55658
2 changed files with 55 additions and 0 deletions

View File

@ -8809,3 +8809,50 @@ module.child:
t.Fatalf("wrong final state\ngot:\n%s\nwant:\n%s", got, want)
}
}
func TestContext2Apply_destroyWithLocals(t *testing.T) {
m := testModule(t, "apply-destroy-with-locals")
ctx := testContext2(t, &ContextOpts{
Module: m,
ProviderResolver: ResourceProviderResolverFixed(
map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(testProvider("aws")),
},
),
State: &State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
Outputs: map[string]*OutputState{
"name": &OutputState{
Type: "string",
Value: "test-bar",
},
},
Resources: map[string]*ResourceState{
"aws_instance.foo": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "foo",
},
},
},
},
},
},
Destroy: true,
})
state, err := ctx.Apply()
if err != nil {
t.Fatalf("error during apply: %s", err)
}
got := strings.TrimSpace(state.String())
want := strings.TrimSpace(`
TODO
`)
if got != want {
t.Fatalf("wrong final state\ngot:\n%s\nwant:\n%s", got, want)
}
}

View File

@ -0,0 +1,8 @@
locals {
name = "test-${aws_instance.foo.id}"
}
resource "aws_instance" "foo" {}
output "name" {
value = "${local.name}"
}