@nboukeffa wrote:
Hi guys,
I would like to know if it’s possible to test the property’s value of a list item in an acceptance test. In the following example I want to verify that the networks list has been correctly modified. Thanks for your help.
const testAccInstanceConfig = ` resource "foo" "bar" { name = "foobar" networks = [ {code = "123", order = 1} ] } ` const testAccCheckInstanceConfigTagsUpdate = ` resource "foo" "bar" { name = "foobar" networks = [ {code = "456", order = 1} ] } ` resource.Test(t, resource.TestCase{ Steps: []resource.TestStep{ { Config: testAccInstanceConfig, Check: resource.ComposeTestCheckFunc( testAccCheckInstanceExists("foo.bar", &v), resource.TestCheckResourceAttr("foo.bar", "networks[0].code", "123"), ), }, { Config: testAccCheckInstanceConfigTagsUpdate, Check: resource.ComposeTestCheckFunc( testAccCheckInstanceExists("foo.bar", &v), resource.TestCheckResourceAttr("foo.bar", "networks[0].code", "456"), ), }, }, })
Posts: 1
Participants: 1