mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
7a4893f83c
Stackdriver notification channel
80 lines
2.1 KiB
Go
80 lines
2.1 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 TestAccMonitoringNotificationChannel_notificationChannelBasicExample(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckMonitoringNotificationChannelDestroy,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccMonitoringNotificationChannel_notificationChannelBasicExample(acctest.RandString(10)),
|
|
},
|
|
{
|
|
ResourceName: "google_monitoring_notification_channel.basic",
|
|
ImportState: true,
|
|
ImportStateVerify: true,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccMonitoringNotificationChannel_notificationChannelBasicExample(val string) string {
|
|
return fmt.Sprintf(`
|
|
resource "google_monitoring_notification_channel" "basic" {
|
|
display_name = "Test Notification Channel-%s"
|
|
type = "email"
|
|
labels = {
|
|
email_address = "fake_email@blahblah.com"
|
|
}
|
|
}
|
|
`, val,
|
|
)
|
|
}
|
|
|
|
func testAccCheckMonitoringNotificationChannelDestroy(s *terraform.State) error {
|
|
for _, rs := range s.RootModule().Resources {
|
|
if rs.Type != "google_monitoring_notification_channel" {
|
|
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("MonitoringNotificationChannel still exists at %s", url)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|