github.com/peterbale/terraform@v0.9.0-beta2.0.20170315142748-5723acd55547/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 Providers: testAccProviders, 12 Steps: []resource.TestStep{ 13 resource.TestStep{ 14 Config: testAccDataConsulKeysConfig, 15 Check: resource.ComposeTestCheckFunc( 16 testAccCheckConsulKeysValue("data.consul_keys.read", "read", "written"), 17 ), 18 }, 19 }, 20 }) 21 } 22 23 const testAccDataConsulKeysConfig = ` 24 resource "consul_keys" "write" { 25 datacenter = "dc1" 26 27 key { 28 path = "test/data_source" 29 value = "written" 30 } 31 } 32 33 data "consul_keys" "read" { 34 # Create a dependency on the resource so we're sure to 35 # have the value in place before we try to read it. 36 datacenter = "${consul_keys.write.datacenter}" 37 38 key { 39 path = "test/data_source" 40 name = "read" 41 } 42 } 43 `