terraform: basic test passing
This commit is contained in:
parent
8bb8637f24
commit
59e498dba8
|
@ -5,7 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestContextImport(t *testing.T) {
|
func TestContextImport_basic(t *testing.T) {
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
ctx := testContext2(t, &ContextOpts{
|
ctx := testContext2(t, &ContextOpts{
|
||||||
Providers: map[string]ResourceProviderFactory{
|
Providers: map[string]ResourceProviderFactory{
|
||||||
|
@ -13,6 +13,13 @@ func TestContextImport(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
p.ImportStateReturn = []*InstanceState{
|
||||||
|
&InstanceState{
|
||||||
|
ID: "foo",
|
||||||
|
Ephemeral: EphemeralState{Type: "aws_instance"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
state, err := ctx.Import(&ImportOpts{
|
state, err := ctx.Import(&ImportOpts{
|
||||||
Targets: []*ImportTarget{
|
Targets: []*ImportTarget{
|
||||||
&ImportTarget{
|
&ImportTarget{
|
||||||
|
@ -32,4 +39,8 @@ func TestContextImport(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testImportStr = ``
|
const testImportStr = `
|
||||||
|
aws_instance.foo:
|
||||||
|
ID = foo
|
||||||
|
provider = aws
|
||||||
|
`
|
||||||
|
|
|
@ -47,6 +47,7 @@ func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("STATE: %#v", state)
|
||||||
if n.Output != nil {
|
if n.Output != nil {
|
||||||
*n.Output = state
|
*n.Output = state
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,9 @@ func (n *graphNodeImportState) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
||||||
// is safe.
|
// is safe.
|
||||||
for _, state := range n.states {
|
for _, state := range n.states {
|
||||||
g.Add(&graphNodeImportStateSub{
|
g.Add(&graphNodeImportStateSub{
|
||||||
State: state,
|
Target: n.Addr,
|
||||||
|
Path_: n.Path(),
|
||||||
|
State: state,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +165,7 @@ func (n *graphNodeImportStateSub) EvalTree() EvalNode {
|
||||||
Provider: &provider,
|
Provider: &provider,
|
||||||
State: &state,
|
State: &state,
|
||||||
Info: info,
|
Info: info,
|
||||||
|
Output: &state,
|
||||||
},
|
},
|
||||||
&EvalWriteState{
|
&EvalWriteState{
|
||||||
Name: key.String(),
|
Name: key.String(),
|
||||||
|
|
Loading…
Reference in New Issue