terraform/builtin/providers/consul/data_source_consul_keys_tes...

44 lines
890 B
Go
Raw Normal View History

package consul
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDataConsulKeys_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDataConsulKeysConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckConsulKeysValue("data.consul_keys.read", "read", "written"),
),
},
},
})
}
const testAccDataConsulKeysConfig = `
resource "consul_keys" "write" {
datacenter = "dc1"
key {
path = "test/data_source"
value = "written"
}
}
data "consul_keys" "read" {
# Create a dependency on the resource so we're sure to
# have the value in place before we try to read it.
datacenter = "${consul_keys.write.datacenter}"
key {
path = "test/data_source"
name = "read"
}
}
`