From 168354c2e863184e62994de6d5690eebdf58816d Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 10 May 2018 09:34:14 -0700 Subject: [PATCH] core: Tests for scale in and out need to mock EvalExpression Since expression evaluation is now done via an EvalContext method, and since these tests use the MockEvalContext, we need to provide a value for the mock call to return. Previously expression evaluation happened at a different layer that was not mocked here. --- terraform/node_data_refresh_test.go | 11 +++++++++++ terraform/node_resource_refresh_test.go | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/terraform/node_data_refresh_test.go b/terraform/node_data_refresh_test.go index f856d561d..ed00303c1 100644 --- a/terraform/node_data_refresh_test.go +++ b/terraform/node_data_refresh_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/hashicorp/terraform/addrs" + "github.com/zclconf/go-cty/cty" ) func TestNodeRefreshableDataResourceDynamicExpand_scaleOut(t *testing.T) { @@ -53,6 +54,11 @@ func TestNodeRefreshableDataResourceDynamicExpand_scaleOut(t *testing.T) { PathPath: addrs.RootModuleInstance, StateState: state, StateLock: &stateLock, + + // DynamicExpand will call EvaluateExpr to evaluate the "count" + // expression, which is just a literal number 3 in the fixture config + // and so we'll just hard-code this here too. + EvaluateExprResult: cty.NumberIntVal(3), }) if err != nil { t.Fatalf("error on DynamicExpand: %s", err) @@ -134,6 +140,11 @@ func TestNodeRefreshableDataResourceDynamicExpand_scaleIn(t *testing.T) { PathPath: addrs.RootModuleInstance, StateState: state, StateLock: &stateLock, + + // DynamicExpand will call EvaluateExpr to evaluate the "count" + // expression, which is just a literal number 3 in the fixture config + // and so we'll just hard-code this here too. + EvaluateExprResult: cty.NumberIntVal(3), }) if err != nil { t.Fatalf("error on DynamicExpand: %s", err) diff --git a/terraform/node_resource_refresh_test.go b/terraform/node_resource_refresh_test.go index 67033df57..d1109d02c 100644 --- a/terraform/node_resource_refresh_test.go +++ b/terraform/node_resource_refresh_test.go @@ -5,6 +5,8 @@ import ( "sync" "testing" + "github.com/zclconf/go-cty/cty" + "github.com/hashicorp/terraform/addrs" "github.com/davecgh/go-spew/spew" @@ -54,6 +56,11 @@ func TestNodeRefreshableManagedResourceDynamicExpand_scaleOut(t *testing.T) { PathPath: addrs.RootModuleInstance, StateState: state, StateLock: &stateLock, + + // DynamicExpand will call EvaluateExpr to evaluate the "count" + // expression, which is just a literal number 3 in the fixture config + // and so we'll just hard-code this here too. + EvaluateExprResult: cty.NumberIntVal(3), }) if err != nil { t.Fatalf("error attempting DynamicExpand: %s", err) @@ -133,6 +140,11 @@ func TestNodeRefreshableManagedResourceDynamicExpand_scaleIn(t *testing.T) { PathPath: addrs.RootModuleInstance, StateState: state, StateLock: &stateLock, + + // DynamicExpand will call EvaluateExpr to evaluate the "count" + // expression, which is just a literal number 3 in the fixture config + // and so we'll just hard-code this here too. + EvaluateExprResult: cty.NumberIntVal(3), }) if err != nil { t.Fatalf("error attempting DynamicExpand: %s", err)