mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 09:36:44 +00:00
37 lines
867 B
Go
37 lines
867 B
Go
![]() |
package google
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/hashicorp/terraform/helper/resource"
|
||
|
)
|
||
|
|
||
|
func TestAccDataSourceGoogleProjects_basic(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
project := getTestProjectFromEnv()
|
||
|
|
||
|
resource.Test(t, resource.TestCase{
|
||
|
PreCheck: func() { testAccPreCheck(t) },
|
||
|
Providers: testAccProviders,
|
||
|
Steps: []resource.TestStep{
|
||
|
{
|
||
|
Config: testAccCheckGoogleProjectsConfig(project),
|
||
|
Check: resource.ComposeTestCheckFunc(
|
||
|
// We can't guarantee no project won't have our project ID as a prefix, so we'll check set-ness rather than correctness
|
||
|
resource.TestCheckResourceAttrSet("data.google_projects.my-project", "projects.0.project_id"),
|
||
|
),
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testAccCheckGoogleProjectsConfig(project string) string {
|
||
|
return fmt.Sprintf(`
|
||
|
data "google_projects" "my-project" {
|
||
|
filter = "projectId:%s"
|
||
|
}
|
||
|
`, project)
|
||
|
}
|