mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 17:16:44 +00:00
![Kit Ewbank](/assets/img/avatar_default.png)
* Add 'google_organization' data source. * Use 'GetResourceNameFromSelfLink'. * Remove 'resourcemanager_helpers'. * Use 'ConflictsWith' in schema. * Add 'organization' argument and make 'name' an output-only attribute.
78 lines
2.0 KiB
Go
78 lines
2.0 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestAccDataSourceGoogleOrganization_byFullName(t *testing.T) {
|
|
orgId := getTestOrgFromEnv(t)
|
|
name := "organizations/" + orgId
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccCheckGoogleOrganization_byName(name),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr("data.google_organization.org", "id", orgId),
|
|
resource.TestCheckResourceAttr("data.google_organization.org", "name", name),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestAccDataSourceGoogleOrganization_byShortName(t *testing.T) {
|
|
orgId := getTestOrgFromEnv(t)
|
|
name := "organizations/" + orgId
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccCheckGoogleOrganization_byName(orgId),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr("data.google_organization.org", "id", orgId),
|
|
resource.TestCheckResourceAttr("data.google_organization.org", "name", name),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestAccDataSourceGoogleOrganization_byDomain(t *testing.T) {
|
|
name := acctest.RandString(16) + ".com"
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccCheckGoogleOrganization_byDomain(name),
|
|
ExpectError: regexp.MustCompile("Organization not found: " + name),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccCheckGoogleOrganization_byName(name string) string {
|
|
return fmt.Sprintf(`
|
|
data "google_organization" "org" {
|
|
organization = "%s"
|
|
}`, name)
|
|
}
|
|
|
|
func testAccCheckGoogleOrganization_byDomain(name string) string {
|
|
return fmt.Sprintf(`
|
|
data "google_organization" "org" {
|
|
domain = "%s"
|
|
}`, name)
|
|
}
|