github.com/mohanarpit/terraform@v0.6.16-0.20160909104007-291f29853544/builtin/providers/datadog/import_datadog_monitor_test.go (about)

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