terraform: basic test passing

This commit is contained in:
Mitchell Hashimoto 2016-04-28 19:25:58 +02:00
parent 8bb8637f24
commit 59e498dba8
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 18 additions and 3 deletions

View File

@ -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
`

View File

@ -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
} }

View File

@ -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(),