github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/datadog/import_datadog_monitor_test.go (about)

     1  package datadog
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/terraform/helper/resource"
     7  )
     8  
     9  func TestDatadogMonitor_import(t *testing.T) {
    10  	resourceName := "datadog_monitor.foo"
    11  
    12  	resource.Test(t, resource.TestCase{
    13  		PreCheck:     func() { testAccPreCheck(t) },
    14  		Providers:    testAccProviders,
    15  		CheckDestroy: testAccCheckDatadogMonitorDestroy,
    16  		Steps: []resource.TestStep{
    17  			resource.TestStep{
    18  				Config: testAccCheckDatadogMonitorConfigImported,
    19  			},
    20  			resource.TestStep{
    21  				ResourceName:      resourceName,
    22  				ImportState:       true,
    23  				ImportStateVerify: true,
    24  			},
    25  		},
    26  	})
    27  }
    28  
    29  const testAccCheckDatadogMonitorConfigImported = `
    30  resource "datadog_monitor" "foo" {
    31    name = "name for monitor foo"
    32    type = "metric alert"
    33    message = "some message Notify: @hipchat-channel"
    34    escalation_message = "the situation has escalated @pagerduty"
    35  
    36    query = "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2.5"
    37  
    38    thresholds {
    39      ok = 1.5
    40      warning = 2.3
    41      critical = 2.5
    42    }
    43  
    44    notify_no_data = false
    45    new_host_delay = 600
    46    renotify_interval = 60
    47  
    48    notify_audit = false
    49    timeout_h = 60
    50    include_tags = true
    51    require_full_window = true
    52    locked = false
    53    tags = ["foo:bar", "bar:baz"]
    54  }
    55  `