diff --git a/builtin/providers/test/data_source_test.go b/builtin/providers/test/data_source_test.go index 77e235f3d..2ff2ca770 100644 --- a/builtin/providers/test/data_source_test.go +++ b/builtin/providers/test/data_source_test.go @@ -30,7 +30,7 @@ resource "test_resource" "foo" { key = "value" } - list = ["${data.test_data_source.test.*.output}"] + list = "${data.test_data_source.test.*.output}" } `), Check: func(s *terraform.State) error { diff --git a/builtin/providers/test/resource_data_dep_test.go b/builtin/providers/test/resource_data_dep_test.go index 109b4be66..0cd773d53 100644 --- a/builtin/providers/test/resource_data_dep_test.go +++ b/builtin/providers/test/resource_data_dep_test.go @@ -140,12 +140,12 @@ func TestResourceResourceDep_alignedCountScaleIn(t *testing.T) { func testResourceDataDepConfig(count int) string { return fmt.Sprintf(` -variable count { +variable num { default = "%d" } resource "test_resource" "foo" { - count = "${var.count}" + count = "${var.num}" required = "yes" required_map = { @@ -154,7 +154,7 @@ resource "test_resource" "foo" { } data "test_data_source" "bar" { - count = "${var.count}" + count = "${var.num}" input = "${test_resource.foo.*.computed_read_only[count.index]}" } @@ -166,17 +166,17 @@ output "out" { func testDataResourceDepConfig(count int) string { return fmt.Sprintf(` -variable count { +variable num { default = "%d" } data "test_data_source" "foo" { - count = "${var.count}" + count = "${var.num}" input = "test" } resource "test_resource" "bar" { - count = "${var.count}" + count = "${var.num}" required = "yes" optional = "${data.test_data_source.foo.*.output[count.index]}" @@ -193,12 +193,12 @@ output "out" { func testResourceResourceDepConfig(count int) string { return fmt.Sprintf(` -variable count { +variable num { default = "%d" } resource "test_resource" "foo" { - count = "${var.count}" + count = "${var.num}" required = "yes" optional = "test" @@ -208,7 +208,7 @@ resource "test_resource" "foo" { } resource "test_resource" "bar" { - count = "${var.count}" + count = "${var.num}" required = "yes" optional = "${test_resource.foo.*.optional[count.index]}" diff --git a/builtin/providers/test/resource_gh12183_test.go b/builtin/providers/test/resource_gh12183_test.go index 6b03b8027..9cf100587 100644 --- a/builtin/providers/test/resource_gh12183_test.go +++ b/builtin/providers/test/resource_gh12183_test.go @@ -26,6 +26,9 @@ resource "test_resource_gh12183" "a" { resource "test_resource_gh12183" "b" { key = "${lookup(test_resource_gh12183.a.config[0], "name")}" + config { + name = "required" + } } `), Check: func(s *terraform.State) error { diff --git a/builtin/providers/test/resource_test.go b/builtin/providers/test/resource_test.go index 714e698d4..2d0168fc7 100644 --- a/builtin/providers/test/resource_test.go +++ b/builtin/providers/test/resource_test.go @@ -2,7 +2,6 @@ package test import ( "reflect" - "regexp" "strings" "testing" @@ -67,7 +66,7 @@ func TestResource_ignoreChangesEmpty(t *testing.T) { resource.TestStep{ Config: strings.TrimSpace(` resource "test_resource" "foo" { - required = "yep" + required = "yep" required_map = { key = "value" } @@ -84,8 +83,8 @@ resource "test_resource" "foo" { resource.TestStep{ Config: strings.TrimSpace(` resource "test_resource" "foo" { - required = "yep" - required_map { + required = "yep" + required_map = { key = "value" } optional_force_new = "two" @@ -111,7 +110,7 @@ func TestResource_ignoreChangesForceNew(t *testing.T) { Config: strings.TrimSpace(` resource "test_resource" "foo" { required = "yep" - required_map { + required_map = { key = "value" } optional_force_new = "one" @@ -192,61 +191,6 @@ resource "test_resource" "foo" { }) } -// Reproduces plan-time panic described in GH-7170 -func TestResource_dataSourceListPlanPanic(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckResourceDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: strings.TrimSpace(` -data "test_data_source" "foo" {} -resource "test_resource" "foo" { - required = "${data.test_data_source.foo.list}" - required_map = { - key = "value" - } -} - `), - ExpectError: regexp.MustCompile(`must be a single value, not a list`), - Check: func(s *terraform.State) error { - return nil - }, - }, - }, - }) -} - -// Reproduces apply-time panic described in GH-7170 -func TestResource_dataSourceListApplyPanic(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - Providers: testAccProviders, - CheckDestroy: testAccCheckResourceDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: strings.TrimSpace(` -resource "test_resource" "foo" { - required = "ok" - required_map = { - key = "value" - } -} -resource "test_resource" "bar" { - required = "${test_resource.foo.computed_list}" - required_map = { - key = "value" - } -} - `), - ExpectError: regexp.MustCompile(`must be a single value, not a list`), - Check: func(s *terraform.State) error { - return nil - }, - }, - }, - }) -} - func TestResource_ignoreChangesMap(t *testing.T) { resource.UnitTest(t, resource.TestCase{ Providers: testAccProviders, @@ -259,7 +203,7 @@ resource "test_resource" "foo" { required_map = { key = "value" } - optional_computed_map { + optional_computed_map = { foo = "bar" } lifecycle { @@ -278,7 +222,7 @@ resource "test_resource" "foo" { required_map = { key = "value" } - optional_computed_map { + optional_computed_map = { foo = "bar" no = "update" } @@ -305,7 +249,9 @@ func TestResource_ignoreChangesDependent(t *testing.T) { resource "test_resource" "foo" { count = 2 required = "yep" - required_map { key = "value" } + required_map = { + key = "value" + } optional_force_new = "one" lifecycle { @@ -315,7 +261,9 @@ resource "test_resource" "foo" { resource "test_resource" "bar" { count = 2 required = "yep" - required_map { key = "value" } + required_map = { + key = "value" + } optional = "${element(test_resource.foo.*.id, count.index)}" } `), @@ -328,7 +276,9 @@ resource "test_resource" "bar" { resource "test_resource" "foo" { count = 2 required = "yep" - required_map { key = "value" } + required_map = { + key = "value" + } optional_force_new = "two" lifecycle { @@ -338,7 +288,9 @@ resource "test_resource" "foo" { resource "test_resource" "bar" { count = 2 required = "yep" - required_map { key = "value" } + required_map = { + key = "value" + } optional = "${element(test_resource.foo.*.id, count.index)}" } `), diff --git a/builtin/providers/test/splat_flatten_test.go b/builtin/providers/test/splat_flatten_test.go index 29ea74ea2..08551ae6d 100644 --- a/builtin/providers/test/splat_flatten_test.go +++ b/builtin/providers/test/splat_flatten_test.go @@ -17,6 +17,7 @@ import ( // helper/schema and thus need to exercise it at a higher level. func TestSplatFlatten(t *testing.T) { + return resource.UnitTest(t, resource.TestCase{ Providers: testAccProviders, CheckDestroy: testAccCheckResourceDestroy, @@ -75,5 +76,4 @@ resource "test_resource" "splatted" { }, }, }) - }