data sources now show up in the initial plan

This commit is contained in:
James Bardin 2020-09-16 16:25:51 -04:00
parent 312317abd0
commit 86dd8938c9
2 changed files with 35 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import (
"testing"
"github.com/hashicorp/terraform/e2e"
"github.com/hashicorp/terraform/plans"
)
// The tests in this file run through different scenarios recommended in our
@ -72,11 +73,25 @@ func TestPlanApplyInAutomation(t *testing.T) {
// stateResources := plan.Changes.Resources
diffResources := plan.Changes.Resources
if len(diffResources) != 1 || diffResources[0].Addr.String() != "null_resource.test" {
if len(diffResources) != 2 {
t.Errorf("incorrect number of resources in plan")
}
expected := map[string]plans.Action{
"data.template_file.test": plans.Read,
"null_resource.test": plans.Create,
}
for _, r := range diffResources {
expectedAction, ok := expected[r.Addr.String()]
if !ok {
t.Fatalf("unexpected change for %q", r.Addr)
}
if r.Action != expectedAction {
t.Fatalf("unexpected action %q for %q", r.Action, r.Addr)
}
}
//// APPLY
stdout, stderr, err = tf.Run("apply", "-input=false", "tfplan")
if err != nil {

View File

@ -9,6 +9,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/terraform/e2e"
"github.com/hashicorp/terraform/plans"
"github.com/zclconf/go-cty/cty"
)
@ -71,8 +72,23 @@ func TestPrimarySeparatePlan(t *testing.T) {
}
diffResources := plan.Changes.Resources
if len(diffResources) != 1 || diffResources[0].Addr.String() != "null_resource.test" {
t.Errorf("incorrect diff in plan; want just null_resource.test to have been rendered, but have:\n%s", spew.Sdump(diffResources))
if len(diffResources) != 2 {
t.Errorf("incorrect number of resources in plan")
}
expected := map[string]plans.Action{
"data.template_file.test": plans.Read,
"null_resource.test": plans.Create,
}
for _, r := range diffResources {
expectedAction, ok := expected[r.Addr.String()]
if !ok {
t.Fatalf("unexpected change for %q", r.Addr)
}
if r.Action != expectedAction {
t.Fatalf("unexpected action %q for %q", r.Action, r.Addr)
}
}
//// APPLY