create a test that removes a RequiresReplace path

One of the paths that triggers RequiresReplace does not apply to the
new value.
This commit is contained in:
James Bardin 2019-02-12 11:48:36 -05:00
parent fbde1b20f0
commit f932e11a50
2 changed files with 35 additions and 0 deletions

View File

@ -25,6 +25,11 @@ func testResourceList() *schema.Resource {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
}, },
"force_new": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"sublist_block": { "sublist_block": {
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,

View File

@ -188,3 +188,33 @@ resource "test_resource_list" "bar" {
}, },
}) })
} }
func TestResourceList_removedForcesNew(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 {
force_new = "ok"
}
}
`),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"test_resource_list.foo", "list_block.0.force_new", "ok",
),
),
},
resource.TestStep{
Config: strings.TrimSpace(`
resource "test_resource_list" "foo" {
}
`),
Check: resource.ComposeTestCheckFunc(),
},
},
})
}