terraform: test multiple return values
This commit is contained in:
parent
2ed23778b4
commit
cfa58a25a6
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue