diff --git a/backend/local/backend_plan.go b/backend/local/backend_plan.go index 3689c190a..6d2639d32 100644 --- a/backend/local/backend_plan.go +++ b/backend/local/backend_plan.go @@ -171,7 +171,6 @@ func (b *Local) opPlan( path, path, )) } - } } } diff --git a/backend/local/backend_plan_test.go b/backend/local/backend_plan_test.go index 9c454718a..e58d03f67 100644 --- a/backend/local/backend_plan_test.go +++ b/backend/local/backend_plan_test.go @@ -131,10 +131,11 @@ func TestLocal_planNoConfig(t *testing.T) { func TestLocal_planRefreshFalse(t *testing.T) { b, cleanup := TestLocal(t) defer cleanup() - p := TestLocalProvider(t, b, "test", &terraform.ProviderSchema{}) + + p := TestLocalProvider(t, b, "test", planFixtureSchema()) terraform.TestStateFile(t, b.StatePath, testPlanState()) - op, configCleanup := testOperationPlan(t, "./test-fixtures/empty") + op, configCleanup := testOperationPlan(t, "./test-fixtures/plan") defer configCleanup() run, err := b.Operation(context.Background(), op) @@ -158,6 +159,7 @@ func TestLocal_planRefreshFalse(t *testing.T) { func TestLocal_planDestroy(t *testing.T) { b, cleanup := TestLocal(t) defer cleanup() + p := TestLocalProvider(t, b, "test", planFixtureSchema()) terraform.TestStateFile(t, b.StatePath, testPlanState()) @@ -167,7 +169,7 @@ func TestLocal_planDestroy(t *testing.T) { op, configCleanup := testOperationPlan(t, "./test-fixtures/plan") defer configCleanup() - op.Destroy = false + op.Destroy = true op.PlanRefresh = true op.PlanOutPath = planPath @@ -189,16 +191,11 @@ func TestLocal_planDestroy(t *testing.T) { } plan := testReadPlan(t, planPath) - // This statement can be removed when the test is fixed and replaced with the - // commented-out test below. - if plan == nil { - t.Fatalf("plan is nil") + for _, r := range plan.Changes.Resources { + if r.Action.String() != "Delete" { + t.Fatalf("bad: %#v", r.Action.String()) + } } - // for _, r := range plan.Changes.Resources { - // if !r.Destroy { - // t.Fatalf("bad: %#v", r) - // } - // } } func TestLocal_planOutPathNoChange(t *testing.T) { @@ -340,6 +337,9 @@ func testReadPlan(t *testing.T, path string) *plans.Plan { defer p.Close() plan, err := p.ReadPlan() + if err != nil { + t.Fatalf("err: %s", err) + } return plan } diff --git a/plans/planfile/tfplan.go b/plans/planfile/tfplan.go index 2db909b9f..6e4972fda 100644 --- a/plans/planfile/tfplan.go +++ b/plans/planfile/tfplan.go @@ -277,6 +277,10 @@ func changeFromTfplan(rawChange *planproto.Change) (*plans.ChangeSrc, error) { } func valueFromTfplan(rawV *planproto.DynamicValue) (plans.DynamicValue, error) { + if rawV.Msgpack == nil { + return plans.DynamicValue(nil), nil + } + if len(rawV.Msgpack) == 0 { // len(0) because that's the default value for a "bytes" in protobuf return nil, fmt.Errorf("dynamic value does not have msgpack serialization") }