Skip to content

Commit

Permalink
add a trouble test schema from the aws provider
Browse files Browse the repository at this point in the history
jbardin committed Feb 14, 2019
1 parent 8f3ee18 commit 931f459
Showing 2 changed files with 182 additions and 0 deletions.
119 changes: 119 additions & 0 deletions builtin/providers/test/resource_list_set.go
Original file line number Diff line number Diff line change
@@ -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,
},
},
},
},
},
},
},
},
},
},
},
}
}
63 changes: 63 additions & 0 deletions builtin/providers/test/resource_list_set_test.go
Original file line number Diff line number Diff line change
@@ -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"),
),
},
},
})
}

0 comments on commit 931f459

Please sign in to comment.