github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/consul/data_source_consul_keys_test.go (about) 1 package consul 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/terraform/helper/resource" 7 ) 8 9 func TestAccDataConsulKeys_basic(t *testing.T) { 10 resource.Test(t, resource.TestCase{ 11 PreCheck: func() { testAccPreCheck(t) }, 12 Providers: testAccProviders, 13 Steps: []resource.TestStep{ 14 resource.TestStep{ 15 Config: testAccDataConsulKeysConfig, 16 Check: resource.ComposeTestCheckFunc( 17 testAccCheckConsulKeysValue("data.consul_keys.read", "read", "written"), 18 ), 19 }, 20 }, 21 }) 22 } 23 24 const testAccDataConsulKeysConfig = ` 25 resource "consul_keys" "write" { 26 datacenter = "dc1" 27 28 key { 29 path = "test/data_source" 30 value = "written" 31 } 32 } 33 34 data "consul_keys" "read" { 35 # Create a dependency on the resource so we're sure to 36 # have the value in place before we try to read it. 37 datacenter = "${consul_keys.write.datacenter}" 38 39 key { 40 path = "test/data_source" 41 name = "read" 42 } 43 } 44 `