From 59e498dba86329eb0750f524ef54005816ede809 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 28 Apr 2016 19:25:58 +0200 Subject: [PATCH] terraform: basic test passing --- terraform/context_import_test.go | 15 +++++++++++++-- terraform/eval_refresh.go | 1 + terraform/transform_import_state.go | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/terraform/context_import_test.go b/terraform/context_import_test.go index 2b633ae6a..eee2151dd 100644 --- a/terraform/context_import_test.go +++ b/terraform/context_import_test.go @@ -5,7 +5,7 @@ import ( "testing" ) -func TestContextImport(t *testing.T) { +func TestContextImport_basic(t *testing.T) { p := testProvider("aws") ctx := testContext2(t, &ContextOpts{ 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{ Targets: []*ImportTarget{ &ImportTarget{ @@ -32,4 +39,8 @@ func TestContextImport(t *testing.T) { } } -const testImportStr = `` +const testImportStr = ` +aws_instance.foo: + ID = foo + provider = aws +` diff --git a/terraform/eval_refresh.go b/terraform/eval_refresh.go index fa2b8126c..75e9e1c77 100644 --- a/terraform/eval_refresh.go +++ b/terraform/eval_refresh.go @@ -47,6 +47,7 @@ func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error) { return nil, err } + log.Printf("STATE: %#v", state) if n.Output != nil { *n.Output = state } diff --git a/terraform/transform_import_state.go b/terraform/transform_import_state.go index dcbc380bd..53c03a22b 100644 --- a/terraform/transform_import_state.go +++ b/terraform/transform_import_state.go @@ -97,7 +97,9 @@ func (n *graphNodeImportState) DynamicExpand(ctx EvalContext) (*Graph, error) { // is safe. for _, state := range n.states { g.Add(&graphNodeImportStateSub{ - State: state, + Target: n.Addr, + Path_: n.Path(), + State: state, }) } @@ -163,6 +165,7 @@ func (n *graphNodeImportStateSub) EvalTree() EvalNode { Provider: &provider, State: &state, Info: info, + Output: &state, }, &EvalWriteState{ Name: key.String(),