opentofu/builtin/providers/ovh/data_source_ovh_publiccloud_regions_test.go
yanndegat 21d8125d5c provider/ovh: new provider (#12669)
* vendor: add go-ovh

* provider/ovh: new provider

* provider/ovh: Adding PublicCloud User Resource

* provider/ovh: Adding VRack Attachment Resource

* provider/ovh: Adding PublicCloud Network Resource

* provider/ovh: Adding PublicCloud Subnet Resource

* provider/ovh: Adding PublicCloud Regions Datasource

* provider/ovh: Adding PublicCloud Region Datasource

* provider/ovh: Fix Acctests using project's regions
2017-05-16 17:26:43 +03:00

48 lines
1.1 KiB
Go

package ovh
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestAccPublicCloudRegionsDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccPublicCloudRegionsDatasourceConfig,
Check: resource.ComposeTestCheckFunc(
testAccPublicCloudRegionsDatasource("data.ovh_publiccloud_regions.regions"),
),
},
},
})
}
func testAccPublicCloudRegionsDatasource(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Can't find regions data source: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("Cannot find regions for project %s", rs.Primary.Attributes["project_id"])
}
return nil
}
}
var testAccPublicCloudRegionsDatasourceConfig = fmt.Sprintf(`
data "ovh_publiccloud_regions" "regions" {
project_id = "%s"
}
`, os.Getenv("OVH_PUBLIC_CLOUD"))