add a trouble test schema from the aws provider

This commit is contained in:
James Bardin 2019-02-13 19:01:13 -05:00
parent 8f3ee1800d
commit 931f459336
2 changed files with 182 additions and 0 deletions

View File

@ -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,
},
},
},
},
},
},
},
},
},
},
},
}
}

View File

@ -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"),
),
},
},
})
}