Skip to content

Commit

Permalink
Syntax cleanup based on PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
evandbrown committed Dec 13, 2016
1 parent 5f1dd34 commit 74d82b7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
9 changes: 8 additions & 1 deletion builtin/providers/google/import_google_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestAccGoogleProject_importBasic(t *testing.T) {
resourceName := "google_project.acceptance"
conf := fmt.Sprintf(testAccGoogleProject_basic, projectId)
conf := testAccGoogleProject_import(projectId)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -27,3 +27,10 @@ func TestAccGoogleProject_importBasic(t *testing.T) {
},
})
}

func testAccGoogleProject_import(pid string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
}`, pid)
}
3 changes: 0 additions & 3 deletions builtin/providers/google/resource_google_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,6 @@ func resourceServicesDelta(d *schema.ResourceData) (added, removed []string) {
newMap[v.(string)] = true
}

added = make([]string, 0)
removed = make([]string, 0)

// Find removed services
for k, _ := range oldMap {
if newMap[k] {
Expand Down
22 changes: 11 additions & 11 deletions builtin/providers/google/resource_google_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ func multiEnvSearch(ks []string) string {
}

// Test that a Project resource can be created and destroyed
func TestAccGoogleProject_basic(t *testing.T) {
func TestAccGoogleProject_create(t *testing.T) {
pid := "terraform-" + acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccGoogleProjectBasic(pid, name, org),
Config: testAccGoogleProject_create(pid, name, org),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleProjectExists("google_project.acceptance", pid),
),
},
resource.TestStep{
Config: testAccGoogleProjectTwoServices(pid, name, org),
Config: testAccGoogleProject_twoServices(pid, name, org),
},
resource.TestStep{
Config: testAccGoogleProjectOneService(pid, name, org),
Config: testAccGoogleProject_oneService(pid, name, org),
},
},
})
Expand All @@ -65,15 +65,15 @@ func TestAccGoogleProject_iamPolicy1(t *testing.T) {
Steps: []resource.TestStep{
// Create a project
resource.TestStep{
Config: testAccGoogleProjectBasic(pid, name, org),
Config: testAccGoogleProject_create(pid, name, org),
Check: resource.ComposeTestCheckFunc(
testAccGoogleProjectExistingPolicy(pid),
),
},
// Second step applies an IAM policy from a data source. The application
// merges policies, so we validate the expected state.
resource.TestStep{
Config: testAccGoogleProjectPolicy1(pid, name, org),
Config: testAccGoogleProject_policy1(pid, name, org),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleProjectExists("google_project.acceptance", pid),
testAccCheckGoogleProjectIamPolicyIsMerged("google_project.acceptance", "data.google_iam_policy.admin", pid),
Expand All @@ -82,7 +82,7 @@ func TestAccGoogleProject_iamPolicy1(t *testing.T) {
// Finally, remove the custom IAM policy from config and apply, then
// confirm that the project is in its original state.
resource.TestStep{
Config: testAccGoogleProjectBasic(pid, name, org),
Config: testAccGoogleProject_create(pid, name, org),
},
},
})
Expand Down Expand Up @@ -454,7 +454,7 @@ func (b Binding) Less(i, j int) bool {
return b[i].Role < b[j].Role
}

func testAccGoogleProjectBasic(pid, name, org string) string {
func testAccGoogleProject_create(pid, name, org string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
Expand All @@ -463,7 +463,7 @@ resource "google_project" "acceptance" {
}`, pid, name, org)
}

func testAccGoogleProjectTwoServices(pid, name, org string) string {
func testAccGoogleProject_twoServices(pid, name, org string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
Expand All @@ -473,7 +473,7 @@ resource "google_project" "acceptance" {
}`, pid, name, org)
}

func testAccGoogleProjectOneService(pid, name, org string) string {
func testAccGoogleProject_oneService(pid, name, org string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
Expand All @@ -483,7 +483,7 @@ resource "google_project" "acceptance" {
}`, pid, name, org)
}

func testAccGoogleProjectPolicy1(pid, name, org string) string {
func testAccGoogleProject_policy1(pid, name, org string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
Expand Down
5 changes: 1 addition & 4 deletions builtin/providers/google/resourcemanager_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ type ResourceManagerOperationWaiter struct {

func (w *ResourceManagerOperationWaiter) RefreshFunc() resource.StateRefreshFunc {
return func() (interface{}, string, error) {
var op *cloudresourcemanager.Operation
var err error

op, err = w.Service.Operations.Get(w.Op.Name).Do()
op, err := w.Service.Operations.Get(w.Op.Name).Do()

if err != nil {
return nil, "", err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The following arguments are supported:
* `org_id` - (Required) The numeric ID of the organization this project belongs to.
Changing this forces a new project to be created.

* `name` - (Optional) The display name of the project.
* `name` - (Required) The display name of the project.

* `services` - (Optional) The services/APIs that are enabled for this project.
For a list of available services, run `gcloud beta service-management list`
Expand Down

0 comments on commit 74d82b7

Please sign in to comment.