From be127725cc46c48173090407fe548c30f3068bff Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 7 Feb 2019 20:23:39 -0500 Subject: [PATCH] Additional tests with interpolated values --- builtin/providers/test/resource_list_test.go | 55 +++++++++++++++++++ .../test/resource_nested_set_test.go | 53 ++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/builtin/providers/test/resource_list_test.go b/builtin/providers/test/resource_list_test.go index 76c82f15a8..e39b575219 100644 --- a/builtin/providers/test/resource_list_test.go +++ b/builtin/providers/test/resource_list_test.go @@ -133,3 +133,58 @@ resource "test_resource_list" "foo" { }, }) } + +func TestResourceList_interpolationChanges(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + Providers: testAccProviders, + CheckDestroy: testAccCheckResourceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_list" "foo" { + list_block { + string = "x" + } +} +resource "test_resource_list" "bar" { + list_block { + string = test_resource_list.foo.id + } +} + `), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "test_resource_list.foo", "list_block.0.string", "x", + ), + resource.TestCheckResourceAttr( + "test_resource_list.bar", "list_block.0.string", "testId", + ), + ), + }, + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_list" "baz" { + list_block { + string = "x" + int = 1 + } +} +resource "test_resource_list" "bar" { + list_block { + string = test_resource_list.baz.id + int = 3 + } +} + `), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "test_resource_list.baz", "list_block.0.string", "x", + ), + resource.TestCheckResourceAttr( + "test_resource_list.bar", "list_block.0.string", "testId", + ), + ), + }, + }, + }) +} diff --git a/builtin/providers/test/resource_nested_set_test.go b/builtin/providers/test/resource_nested_set_test.go index e47f1ac588..e782bb7fb5 100644 --- a/builtin/providers/test/resource_nested_set_test.go +++ b/builtin/providers/test/resource_nested_set_test.go @@ -527,3 +527,56 @@ resource "test_resource_nested_set" "c" { }, }) } + +func TestResourceNestedSet_interpolationChanges(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + Providers: testAccProviders, + CheckDestroy: testAccCheckResourceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "foo" { + single { + value = "x" + } +} +resource "test_resource_nested_set" "bar" { + single { + value = test_resource_nested_set.foo.id + } +} + `), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "test_resource_nested_set.foo", "single.#", "1", + ), + resource.TestCheckResourceAttr( + "test_resource_nested_set.bar", "single.#", "1", + ), + ), + }, + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "baz" { + single { + value = "x" + } +} +resource "test_resource_nested_set" "bar" { + single { + value = test_resource_nested_set.baz.id + } +} + `), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "test_resource_nested_set.baz", "single.#", "1", + ), + resource.TestCheckResourceAttr( + "test_resource_nested_set.bar", "single.#", "1", + ), + ), + }, + }, + }) +}