From 931f459336dfe22ac1d4872b3e6f35a359b5d008 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 13 Feb 2019 19:01:13 -0500 Subject: [PATCH] add a trouble test schema from the aws provider --- builtin/providers/test/resource_list_set.go | 119 ++++++++++++++++++ .../providers/test/resource_list_set_test.go | 63 ++++++++++ 2 files changed, 182 insertions(+) diff --git a/builtin/providers/test/resource_list_set.go b/builtin/providers/test/resource_list_set.go index 6e83903641..0ce5abc8d5 100644 --- a/builtin/providers/test/resource_list_set.go +++ b/builtin/providers/test/resource_list_set.go @@ -50,6 +50,125 @@ func testResourceListSet() *schema.Resource { }, }, }, + "replication_configuration": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "role": { + Type: schema.TypeString, + Required: true, + }, + "rules": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Optional: true, + }, + "destination": { + Type: schema.TypeSet, + MaxItems: 1, + MinItems: 1, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "account_id": { + Type: schema.TypeString, + Optional: true, + }, + "bucket": { + Type: schema.TypeString, + Required: true, + }, + "storage_class": { + Type: schema.TypeString, + Optional: true, + }, + "replica_kms_key_id": { + Type: schema.TypeString, + Optional: true, + }, + "access_control_translation": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "owner": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + }, + }, + }, + "source_selection_criteria": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "sse_kms_encrypted_objects": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, + }, + }, + }, + "prefix": { + Type: schema.TypeString, + Optional: true, + }, + "status": { + Type: schema.TypeString, + Required: true, + }, + "priority": { + Type: schema.TypeInt, + Optional: true, + }, + "filter": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "prefix": { + Type: schema.TypeString, + Optional: true, + }, + "tags": { + Type: schema.TypeMap, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, }, } } diff --git a/builtin/providers/test/resource_list_set_test.go b/builtin/providers/test/resource_list_set_test.go index 11cb742e8a..f1e8353fb1 100644 --- a/builtin/providers/test/resource_list_set_test.go +++ b/builtin/providers/test/resource_list_set_test.go @@ -53,3 +53,66 @@ resource "test_resource_list_set" "foo" { }, }) } + +func TestResourceListSet_updateNested(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + Providers: testAccProviders, + CheckDestroy: testAccCheckResourceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_list_set" "foo" { + replication_configuration { + role = "role_id" + rules { + id = "foobar" + status = "Enabled" + priority = 42 + filter { + tags = { + ReplicateMe = "Yes" + } + } + destination { + bucket = "bucket_id" + storage_class = "STANDARD" + } + } + } +} + `), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("test_resource_list_set.foo", "replication_configuration.0.rules.#", "1"), + ), + }, + resource.TestStep{ + Config: strings.TrimSpace(` +resource "test_resource_list_set" "foo" { + replication_configuration { + role = "role_id" + rules { + id = "foobar" + status = "Enabled" + priority = 42 + filter { + prefix = "foo" + tags = { + ReplicateMe = "Yes" + AnotherTag = "OK" + } + } + destination { + bucket = "bucket_id" + storage_class = "STANDARD" + } + } + } +} + `), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("test_resource_list_set.foo", "replication_configuration.0.rules.#", "1"), + ), + }, + }, + }) +}