mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-13 10:01:08 -04:00
terraform: test import with module depth of two
This commit is contained in:
@@ -114,6 +114,40 @@ func TestContextImport_module(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextImport_moduleDepth2(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"},
|
||||
},
|
||||
}
|
||||
|
||||
state, err := ctx.Import(&ImportOpts{
|
||||
Targets: []*ImportTarget{
|
||||
&ImportTarget{
|
||||
Addr: "module.a.module.b.aws_instance.foo",
|
||||
ID: "bar",
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(testImportModuleDepth2Str)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
const testImportStr = `
|
||||
aws_instance.foo:
|
||||
ID = foo
|
||||
@@ -128,6 +162,14 @@ module.foo:
|
||||
provider = aws
|
||||
`
|
||||
|
||||
const testImportModuleDepth2Str = `
|
||||
<no state>
|
||||
module.a.b:
|
||||
aws_instance.foo:
|
||||
ID = foo
|
||||
provider = aws
|
||||
`
|
||||
|
||||
const testImportRefreshStr = `
|
||||
aws_instance.foo:
|
||||
ID = foo
|
||||
|
||||
Reference in New Issue
Block a user