From 9c4aed52b370b7dad31aad4b3c13d00efcc459ac Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 6 Sep 2018 15:08:47 -0700 Subject: [PATCH] core: Don't panic in refresh tests Since the refresh walk creates a partial plan to account for objects that are yet to be created, we need to provide at least a basic mock of the PlanProviderChange provider method. For now we're using the old-style "DiffFn" shim interface since that's already available for use in other tests. --- terraform/context_refresh_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/terraform/context_refresh_test.go b/terraform/context_refresh_test.go index 6c20c9586..541c9c525 100644 --- a/terraform/context_refresh_test.go +++ b/terraform/context_refresh_test.go @@ -789,6 +789,11 @@ func TestContext2Refresh_outputPartial(t *testing.T) { p.ReadResourceFn = nil p.ReadResourceResponse = providers.ReadResourceResponse{} + // Refresh creates a partial plan for any instances that don't have + // remote objects yet, to get stub values for interpolation. Therefore + // we need to make DiffFn available to let that complete. + p.DiffFn = testDiffFn + p.GetSchemaReturn = &ProviderSchema{ Provider: &configschema.Block{}, ResourceTypes: map[string]*configschema.Block{ @@ -1395,6 +1400,11 @@ func TestContext2Refresh_noDiffHookOnScaleOut(t *testing.T) { }, } + // Refresh creates a partial plan for any instances that don't have + // remote objects yet, to get stub values for interpolation. Therefore + // we need to make DiffFn available to let that complete. + p.DiffFn = testDiffFn + state := mustShimLegacyState(&State{ Modules: []*ModuleState{ &ModuleState{