mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-07 22:53:08 -06:00
21d8125d5c
* 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
48 lines
1.1 KiB
Go
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"))
|