Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#50 from modular-magician/codeg…
Browse files Browse the repository at this point in the history
…en-pr-631

Move beta providers to their own block in provider.go
  • Loading branch information
rileykarson authored Oct 30, 2018
2 parents 56a32f7 + a861031 commit e34eaba
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 61 deletions.
4 changes: 3 additions & 1 deletion google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ func Provider() terraform.ResourceProvider {
},

ResourcesMap: mergeResourceMaps(
// start beta-only products
GeneratedBinaryAuthorizationResourcesMap,
GeneratedComputeResourcesMap,
GeneratedContainerAnalysisResourcesMap,
GeneratedFilestoreResourcesMap,
// end beta-only products
GeneratedComputeResourcesMap,
GeneratedRedisResourcesMap,
GeneratedResourceManagerResourcesMap,
GeneratedStorageResourcesMap,
Expand Down
29 changes: 26 additions & 3 deletions google-beta/resource_containeranalysis_note_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)

func TestAccContainerAnalysisNote_containerAnalysisNoteBasicExample(t *testing.T) {
func TestAccContainerAnalysisNote_ContainerAnalysisNoteBasicExample(t *testing.T) {
t.Parallel()

resource.Test(t, resource.TestCase{
Expand All @@ -31,7 +32,7 @@ func TestAccContainerAnalysisNote_containerAnalysisNoteBasicExample(t *testing.T
CheckDestroy: testAccCheckContainerAnalysisNoteDestroy,
Steps: []resource.TestStep{
{
Config: testAccContainerAnalysisNote_containerAnalysisNoteBasicExample(acctest.RandString(10)),
Config: testAccContainerAnalysisNote_ContainerAnalysisNoteBasicExample(acctest.RandString(10)),
},
{
ResourceName: "google_container_analysis_note.note",
Expand All @@ -42,7 +43,7 @@ func TestAccContainerAnalysisNote_containerAnalysisNoteBasicExample(t *testing.T
})
}

func testAccContainerAnalysisNote_containerAnalysisNoteBasicExample(val string) string {
func testAccContainerAnalysisNote_ContainerAnalysisNoteBasicExample(val string) string {
return fmt.Sprintf(`
resource "google_container_analysis_note" "note" {
name = "test-attestor-note-%s"
Expand All @@ -55,3 +56,25 @@ resource "google_container_analysis_note" "note" {
`, val,
)
}

func testAccCheckContainerAnalysisNoteDestroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
if rs.Type != "google_container_analysis_note" {
continue
}

config := testAccProvider.Meta().(*Config)

url, err := replaceVarsForTest(rs, "https://containeranalysis.googleapis.com/v1beta1/projects/{{project}}/notes/{{name}}")
if err != nil {
return err
}

_, err = sendRequest(config, "GET", url, nil)
if err == nil {
return fmt.Errorf("ContainerAnalysisNote still exists at %s", url)
}
}

return nil
}
27 changes: 0 additions & 27 deletions google-beta/resource_containeranalysis_note_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)

func TestAccContainerAnalysisNote_basic(t *testing.T) {
Expand Down Expand Up @@ -62,32 +61,6 @@ func TestAccContainerAnalysisNote_update(t *testing.T) {
})
}

func testAccCheckContainerAnalysisNoteDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)

for _, rs := range s.RootModule().Resources {
if rs.Type != "google_container_analysis_note" {
continue
}

project, err := getTestProject(rs.Primary, config)
if err != nil {
return err
}

name := rs.Primary.Attributes["name"]

url := fmt.Sprintf("https://containeranalysis.googleapis.com/v1alpha1/projects/%s/notes/%s", project, name)
_, err = sendRequest(config, "GET", url, nil)

if err == nil {
return fmt.Errorf("Error, container analysis note %s still exists", name)
}
}

return nil
}

func testAccContainerAnalysisNoteBasic(name, readableName string) string {
return fmt.Sprintf(`
resource "google_container_analysis_note" "note" {
Expand Down
29 changes: 26 additions & 3 deletions google-beta/resource_filestore_instance_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)

func TestAccFilestoreInstance_filestoreInstanceBasicExample(t *testing.T) {
func TestAccFilestoreInstance_FilestoreInstanceBasicExample(t *testing.T) {
t.Parallel()

resource.Test(t, resource.TestCase{
Expand All @@ -31,7 +32,7 @@ func TestAccFilestoreInstance_filestoreInstanceBasicExample(t *testing.T) {
CheckDestroy: testAccCheckFilestoreInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstance_filestoreInstanceBasicExample(acctest.RandString(10)),
Config: testAccFilestoreInstance_FilestoreInstanceBasicExample(acctest.RandString(10)),
},
{
ResourceName: "google_filestore_instance.instance",
Expand All @@ -43,7 +44,7 @@ func TestAccFilestoreInstance_filestoreInstanceBasicExample(t *testing.T) {
})
}

func testAccFilestoreInstance_filestoreInstanceBasicExample(val string) string {
func testAccFilestoreInstance_FilestoreInstanceBasicExample(val string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "test-instance-%s"
Expand All @@ -63,3 +64,25 @@ resource "google_filestore_instance" "instance" {
`, val,
)
}

func testAccCheckFilestoreInstanceDestroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
if rs.Type != "google_filestore_instance" {
continue
}

config := testAccProvider.Meta().(*Config)

url, err := replaceVarsForTest(rs, "https://file.googleapis.com/v1beta1/projects/{{project}}/locations/{{zone}}/instances/{{name}}")
if err != nil {
return err
}

_, err = sendRequest(config, "GET", url, nil)
if err == nil {
return fmt.Errorf("FilestoreInstance still exists at %s", url)
}
}

return nil
}
27 changes: 0 additions & 27 deletions google-beta/resource_filestore_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package google

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)

func TestAccFilestoreInstance_basic(t *testing.T) {
Expand Down Expand Up @@ -62,31 +60,6 @@ func TestAccFilestoreInstance_update(t *testing.T) {
})
}

func testAccCheckFilestoreInstanceDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)

for _, rs := range s.RootModule().Resources {
if rs.Type != "google_filestore_instance" {
continue
}

redisIdParts := strings.Split(rs.Primary.ID, "/")
if len(redisIdParts) != 3 {
return fmt.Errorf("Unexpected resource ID %s, expected {project}/{region}/{name}", rs.Primary.ID)
}

project, region, inst := redisIdParts[0], redisIdParts[1], redisIdParts[2]

name := fmt.Sprintf("projects/%s/locations/%s/instances/%s", project, region, inst)
_, err := config.clientFilestore.Projects.Locations.Get(name).Do()
if err == nil {
return fmt.Errorf("Filestore instance still exists")
}
}

return nil
}

func testAccFilestoreInstance_basic(name string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
Expand Down

0 comments on commit e34eaba

Please sign in to comment.