github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/profitbricks/data_source_datacenter_test.go (about) 1 package profitbricks 2 3 import ( 4 "github.com/hashicorp/terraform/helper/resource" 5 "testing" 6 ) 7 8 func TestAccDataSourceDatacenter_matching(t *testing.T) { 9 resource.Test(t, resource.TestCase{ 10 PreCheck: func() { 11 testAccPreCheck(t) 12 }, 13 Providers: testAccProviders, 14 Steps: []resource.TestStep{ 15 { 16 17 Config: testAccDataSourceProfitBricksDataCenter_matching, 18 }, 19 { 20 21 Config: testAccDataSourceProfitBricksDataCenter_matchingWithDataSource, 22 Check: resource.ComposeTestCheckFunc( 23 resource.TestCheckResourceAttr("data.profitbricks_datacenter.foobar", "name", "test_name"), 24 resource.TestCheckResourceAttr("data.profitbricks_datacenter.foobar", "location", "us/las"), 25 ), 26 }, 27 }, 28 }) 29 30 } 31 32 const testAccDataSourceProfitBricksDataCenter_matching = ` 33 resource "profitbricks_datacenter" "foobar" { 34 name = "test_name" 35 location = "us/las" 36 } 37 ` 38 39 const testAccDataSourceProfitBricksDataCenter_matchingWithDataSource = ` 40 resource "profitbricks_datacenter" "foobar" { 41 name = "test_name" 42 location = "us/las" 43 } 44 45 data "profitbricks_datacenter" "foobar" { 46 name = "${profitbricks_datacenter.foobar.name}" 47 location = "us/las" 48 }`