terraform: test multiple return values

This commit is contained in:
Mitchell Hashimoto 2016-04-30 17:04:40 -05:00
parent 2ed23778b4
commit cfa58a25a6
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A

View File

@ -281,6 +281,44 @@ func TestContextImport_moduleExisting(t *testing.T) {
}
}
func TestContextImport_multiState(t *testing.T) {
p := testProvider("aws")
ctx := testContext2(t, &ContextOpts{
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
p.ImportStateReturn = []*InstanceState{
&InstanceState{
ID: "foo",
Ephemeral: EphemeralState{Type: "aws_instance"},
},
&InstanceState{
ID: "bar",
Ephemeral: EphemeralState{Type: "aws_instance_thing"},
},
}
state, err := ctx.Import(&ImportOpts{
Targets: []*ImportTarget{
&ImportTarget{
Addr: "aws_instance.foo",
ID: "bar",
},
},
})
if err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(state.String())
expected := strings.TrimSpace(testImportMultiStr)
if actual != expected {
t.Fatalf("bad: \n%s", actual)
}
}
const testImportStr = `
aws_instance.foo:
ID = foo
@ -322,6 +360,15 @@ module.foo:
provider = aws
`
const testImportMultiStr = `
aws_instance.foo:
ID = foo
provider = aws
aws_instance_thing.foo:
ID = bar
provider = aws
`
const testImportRefreshStr = `
aws_instance.foo:
ID = foo