mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
114 lines
2.9 KiB
Go
114 lines
2.9 KiB
Go
![]() |
// ----------------------------------------------------------------------------
|
||
|
//
|
||
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
||
|
//
|
||
|
// ----------------------------------------------------------------------------
|
||
|
//
|
||
|
// This file is automatically generated by Magic Modules and manual
|
||
|
// changes will be clobbered when the file is regenerated.
|
||
|
//
|
||
|
// Please read more about how to change this file in
|
||
|
// .github/CONTRIBUTING.md.
|
||
|
//
|
||
|
// ----------------------------------------------------------------------------
|
||
|
|
||
|
package google
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||
|
"github.com/hashicorp/terraform/helper/resource"
|
||
|
"github.com/hashicorp/terraform/terraform"
|
||
|
)
|
||
|
|
||
|
func TestAccMonitoringGroup_monitoringGroupBasicExample(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
resource.Test(t, resource.TestCase{
|
||
|
PreCheck: func() { testAccPreCheck(t) },
|
||
|
Providers: testAccProviders,
|
||
|
CheckDestroy: testAccCheckMonitoringGroupDestroy,
|
||
|
Steps: []resource.TestStep{
|
||
|
{
|
||
|
Config: testAccMonitoringGroup_monitoringGroupBasicExample(acctest.RandString(10)),
|
||
|
},
|
||
|
{
|
||
|
ResourceName: "google_monitoring_group.basic",
|
||
|
ImportState: true,
|
||
|
ImportStateVerify: true,
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testAccMonitoringGroup_monitoringGroupBasicExample(val string) string {
|
||
|
return fmt.Sprintf(`
|
||
|
resource "google_monitoring_group" "basic" {
|
||
|
display_name = "New Test Group-%s"
|
||
|
|
||
|
filter = "resource.metadata.region=\"europe-west2\""
|
||
|
}
|
||
|
`, val,
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func TestAccMonitoringGroup_monitoringGroupSubgroupExample(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
resource.Test(t, resource.TestCase{
|
||
|
PreCheck: func() { testAccPreCheck(t) },
|
||
|
Providers: testAccProviders,
|
||
|
CheckDestroy: testAccCheckMonitoringGroupDestroy,
|
||
|
Steps: []resource.TestStep{
|
||
|
{
|
||
|
Config: testAccMonitoringGroup_monitoringGroupSubgroupExample(acctest.RandString(10)),
|
||
|
},
|
||
|
{
|
||
|
ResourceName: "google_monitoring_group.subgroup",
|
||
|
ImportState: true,
|
||
|
ImportStateVerify: true,
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testAccMonitoringGroup_monitoringGroupSubgroupExample(val string) string {
|
||
|
return fmt.Sprintf(`
|
||
|
resource "google_monitoring_group" "parent" {
|
||
|
display_name = "New Test SubGroup-%s"
|
||
|
filter = "resource.metadata.region=\"europe-west2\""
|
||
|
}
|
||
|
|
||
|
resource "google_monitoring_group" "subgroup" {
|
||
|
display_name = "New Test SubGroup-%s"
|
||
|
filter = "resource.metadata.region=\"europe-west2\""
|
||
|
parent_name = "${google_monitoring_group.parent.name}"
|
||
|
}
|
||
|
`, val, val,
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func testAccCheckMonitoringGroupDestroy(s *terraform.State) error {
|
||
|
for _, rs := range s.RootModule().Resources {
|
||
|
if rs.Type != "google_monitoring_group" {
|
||
|
continue
|
||
|
}
|
||
|
|
||
|
config := testAccProvider.Meta().(*Config)
|
||
|
|
||
|
url, err := replaceVarsForTest(rs, "https://monitoring.googleapis.com/v3/{{name}}")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
_, err = sendRequest(config, "GET", url, nil)
|
||
|
if err == nil {
|
||
|
return fmt.Errorf("MonitoringGroup still exists at %s", url)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|