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.
This commit is contained in:
Martin Atkins 2018-05-10 09:34:14 -07:00
parent bec0f56808
commit 168354c2e8
2 changed files with 23 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/zclconf/go-cty/cty"
) )
func TestNodeRefreshableDataResourceDynamicExpand_scaleOut(t *testing.T) { func TestNodeRefreshableDataResourceDynamicExpand_scaleOut(t *testing.T) {
@ -53,6 +54,11 @@ func TestNodeRefreshableDataResourceDynamicExpand_scaleOut(t *testing.T) {
PathPath: addrs.RootModuleInstance, PathPath: addrs.RootModuleInstance,
StateState: state, StateState: state,
StateLock: &stateLock, 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 { if err != nil {
t.Fatalf("error on DynamicExpand: %s", err) t.Fatalf("error on DynamicExpand: %s", err)
@ -134,6 +140,11 @@ func TestNodeRefreshableDataResourceDynamicExpand_scaleIn(t *testing.T) {
PathPath: addrs.RootModuleInstance, PathPath: addrs.RootModuleInstance,
StateState: state, StateState: state,
StateLock: &stateLock, 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 { if err != nil {
t.Fatalf("error on DynamicExpand: %s", err) t.Fatalf("error on DynamicExpand: %s", err)

View File

@ -5,6 +5,8 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/zclconf/go-cty/cty"
"github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/addrs"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
@ -54,6 +56,11 @@ func TestNodeRefreshableManagedResourceDynamicExpand_scaleOut(t *testing.T) {
PathPath: addrs.RootModuleInstance, PathPath: addrs.RootModuleInstance,
StateState: state, StateState: state,
StateLock: &stateLock, 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 { if err != nil {
t.Fatalf("error attempting DynamicExpand: %s", err) t.Fatalf("error attempting DynamicExpand: %s", err)
@ -133,6 +140,11 @@ func TestNodeRefreshableManagedResourceDynamicExpand_scaleIn(t *testing.T) {
PathPath: addrs.RootModuleInstance, PathPath: addrs.RootModuleInstance,
StateState: state, StateState: state,
StateLock: &stateLock, 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 { if err != nil {
t.Fatalf("error attempting DynamicExpand: %s", err) t.Fatalf("error attempting DynamicExpand: %s", err)