diff --git a/builtin/providers/test/resource_nested_set.go b/builtin/providers/test/resource_nested_set.go index 862c6c95b3..c555265c3d 100644 --- a/builtin/providers/test/resource_nested_set.go +++ b/builtin/providers/test/resource_nested_set.go @@ -44,6 +44,37 @@ func testResourceNestedSet() *schema.Resource { }, }, }, + "multi": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "set": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "required": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "optional_int": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + }, + + "optional": { + Type: schema.TypeString, + ForceNew: true, + Optional: true, + }, + }, + }, + }, }, } } diff --git a/builtin/providers/test/resource_nested_set_test.go b/builtin/providers/test/resource_nested_set_test.go index 56dd04bfc3..7a27b75a24 100644 --- a/builtin/providers/test/resource_nested_set_test.go +++ b/builtin/providers/test/resource_nested_set_test.go @@ -127,3 +127,79 @@ resource "test_resource_nested_set" "foo" { }, }) } +func TestResourceNestedSet_multi(t *testing.T) { + checkFunc := func(s *terraform.State) error { + return nil + } + resource.UnitTest(t, resource.TestCase{ + Providers: testAccProviders, + CheckDestroy: testAccCheckResourceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "foo" { +} + `), + Check: checkFunc, + }, + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "foo" { + multi { + optional = "bar" + } +} + `), + Check: checkFunc, + }, + + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "foo" { +} + `), + Check: checkFunc, + }, + + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "foo" { + multi { + set { + required = "val" + } + } +} + `), + Check: checkFunc, + }, + + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "foo" { + multi { + set { + required = "new" + } + } +} + `), + Check: checkFunc, + }, + + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_nested_set" "foo" { + multi { + set { + required = "new" + optional_int = 3 + } + } +} + `), + Check: checkFunc, + }, + }, + }) +}