Skip to content

Commit

Permalink
Add description to service account.
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
nat-henderson authored and modular-magician committed Oct 22, 2019
1 parent dfa8405 commit 7b483c4
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 649 deletions.
40 changes: 10 additions & 30 deletions google-beta/resource_cloudiot_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func TestAccCloudIoTRegistry_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccCloudIoTRegistry_basic(registryName),
Check: resource.ComposeTestCheckFunc(
testAccCloudIoTRegistryExists(
"google_cloudiot_registry.foobar"),
),
},
{
ResourceName: "google_cloudiot_registry.foobar",
Expand All @@ -72,10 +68,6 @@ func TestAccCloudIoTRegistry_extended(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccCloudIoTRegistry_extended(registryName),
Check: resource.ComposeTestCheckFunc(
testAccCloudIoTRegistryExists(
"google_cloudiot_registry.foobar"),
),
},
{
ResourceName: "google_cloudiot_registry.foobar",
Expand All @@ -98,14 +90,20 @@ func TestAccCloudIoTRegistry_update(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccCloudIoTRegistry_basic(registryName),
Check: resource.ComposeTestCheckFunc(
testAccCloudIoTRegistryExists(
"google_cloudiot_registry.foobar"),
),
},
{
ResourceName: "google_cloudiot_registry.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccCloudIoTRegistry_extended(registryName),
},
{
ResourceName: "google_cloudiot_registry.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccCloudIoTRegistry_basic(registryName),
},
Expand Down Expand Up @@ -223,24 +221,6 @@ func testAccCheckCloudIoTRegistryDestroy(s *terraform.State) error {
return nil
}

func testAccCloudIoTRegistryExists(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No ID is set")
}
config := testAccProvider.Meta().(*Config)
_, err := config.clientCloudIoT.Projects.Locations.Registries.Get(rs.Primary.ID).Do()
if err != nil {
return fmt.Errorf("Registry does not exist")
}
return nil
}
}

func testAccCloudIoTRegistry_basic(registryName string) string {
return fmt.Sprintf(`
resource "google_cloudiot_registry" "foobar" {
Expand Down
121 changes: 10 additions & 111 deletions google-beta/resource_compute_autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@ package google

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"google.golang.org/api/compute/v1"
)

func TestAccComputeAutoscaler_update(t *testing.T) {
t.Parallel()

var ascaler compute.Autoscaler

var it_name = fmt.Sprintf("autoscaler-test-%s", acctest.RandString(10))
var tp_name = fmt.Sprintf("autoscaler-test-%s", acctest.RandString(10))
var igm_name = fmt.Sprintf("autoscaler-test-%s", acctest.RandString(10))
Expand All @@ -28,19 +23,19 @@ func TestAccComputeAutoscaler_update(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccComputeAutoscaler_basic(it_name, tp_name, igm_name, autoscaler_name),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeAutoscalerExists(
"google_compute_autoscaler.foobar", &ascaler),
),
},
{
ResourceName: "google_compute_autoscaler.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeAutoscaler_update(it_name, tp_name, igm_name, autoscaler_name),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeAutoscalerExists(
"google_compute_autoscaler.foobar", &ascaler),
testAccCheckComputeAutoscalerUpdated(
"google_compute_autoscaler.foobar", 10),
),
},
{
ResourceName: "google_compute_autoscaler.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand All @@ -61,7 +56,6 @@ func TestAccComputeAutoscaler_multicondition(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccComputeAutoscaler_multicondition(it_name, tp_name, igm_name, autoscaler_name),
Check: testAccCheckComputeAutoscalerMultifunction("google_compute_autoscaler.foobar"),
},
{
ResourceName: "google_compute_autoscaler.foobar",
Expand All @@ -72,101 +66,6 @@ func TestAccComputeAutoscaler_multicondition(t *testing.T) {
})
}

func testAccCheckComputeAutoscalerExists(n string, ascaler *compute.Autoscaler) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("No ID is set")
}

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

idParts := strings.Split(rs.Primary.ID, "/")
zone, name := idParts[0], idParts[1]
found, err := config.clientCompute.Autoscalers.Get(
config.Project, zone, name).Do()
if err != nil {
return err
}

if found.Name != name {
return fmt.Errorf("Autoscaler not found")
}

*ascaler = *found

return nil
}
}

func testAccCheckComputeAutoscalerMultifunction(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("No ID is set")
}

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

idParts := strings.Split(rs.Primary.ID, "/")
zone, name := idParts[0], idParts[1]
found, err := config.clientCompute.Autoscalers.Get(
config.Project, zone, name).Do()
if err != nil {
return err
}

if found.Name != name {
return fmt.Errorf("Autoscaler not found")
}

if found.AutoscalingPolicy.CpuUtilization.UtilizationTarget == 0.5 && found.AutoscalingPolicy.LoadBalancingUtilization.UtilizationTarget == 0.5 {
return nil
}
return fmt.Errorf("Util target for CPU: %f, for LB: %f - should have been 0.5 for each.",
found.AutoscalingPolicy.CpuUtilization.UtilizationTarget,
found.AutoscalingPolicy.LoadBalancingUtilization.UtilizationTarget)

}
}

func testAccCheckComputeAutoscalerUpdated(n string, max int64) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("No ID is set")
}

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

idParts := strings.Split(rs.Primary.ID, "/")
zone, name := idParts[0], idParts[1]
ascaler, err := config.clientCompute.Autoscalers.Get(
config.Project, zone, name).Do()
if err != nil {
return err
}

if ascaler.AutoscalingPolicy.MaxNumReplicas != max {
return fmt.Errorf("maximum replicas incorrect")
}

return nil
}
}

func testAccComputeAutoscaler_scaffolding(it_name, tp_name, igm_name string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
Expand Down
Loading

0 comments on commit 7b483c4

Please sign in to comment.