@@ -121,6 +121,40 @@ func TestAccDatadogMonitor_Updated(t *testing.T) {
121121 })
122122}
123123
124+ func TestAccDatadogMonitor_TrimWhitespace (t * testing.T ) {
125+ resource .Test (t , resource.TestCase {
126+ PreCheck : func () { testAccPreCheck (t ) },
127+ Providers : testAccProviders ,
128+ CheckDestroy : testAccCheckDatadogMonitorDestroy ,
129+ Steps : []resource.TestStep {
130+ resource.TestStep {
131+ Config : testAccCheckDatadogMonitorConfigWhitespace ,
132+ Check : resource .ComposeTestCheckFunc (
133+ testAccCheckDatadogMonitorExists ("datadog_monitor.foo" ),
134+ resource .TestCheckResourceAttr (
135+ "datadog_monitor.foo" , "name" , "name for monitor foo" ),
136+ resource .TestCheckResourceAttr (
137+ "datadog_monitor.foo" , "message" , "some message Notify: @hipchat-channel" ),
138+ resource .TestCheckResourceAttr (
139+ "datadog_monitor.foo" , "type" , "metric alert" ),
140+ resource .TestCheckResourceAttr (
141+ "datadog_monitor.foo" , "query" , "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2" ),
142+ resource .TestCheckResourceAttr (
143+ "datadog_monitor.foo" , "notify_no_data" , "false" ),
144+ resource .TestCheckResourceAttr (
145+ "datadog_monitor.foo" , "renotify_interval" , "60" ),
146+ resource .TestCheckResourceAttr (
147+ "datadog_monitor.foo" , "thresholds.ok" , "0" ),
148+ resource .TestCheckResourceAttr (
149+ "datadog_monitor.foo" , "thresholds.warning" , "1" ),
150+ resource .TestCheckResourceAttr (
151+ "datadog_monitor.foo" , "thresholds.critical" , "2" ),
152+ ),
153+ },
154+ },
155+ })
156+ }
157+
124158func testAccCheckDatadogMonitorDestroy (s * terraform.State ) error {
125159 client := testAccProvider .Meta ().(* datadog.Client )
126160
@@ -191,6 +225,34 @@ resource "datadog_monitor" "foo" {
191225}
192226`
193227
228+ const testAccCheckDatadogMonitorConfigWhitespace = `
229+ resource "datadog_monitor" "foo" {
230+ name = "name for monitor foo"
231+ type = "metric alert"
232+ message = <<EOF
233+ some message Notify: @hipchat-channel
234+ EOF
235+ escalation_message = <<EOF
236+ the situation has escalated @pagerduty
237+ EOF
238+ query = <<EOF
239+ avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2
240+ EOF
241+ thresholds {
242+ ok = 0
243+ warning = 1
244+ critical = 2
245+ }
246+
247+ notify_no_data = false
248+ renotify_interval = 60
249+
250+ notify_audit = false
251+ timeout_h = 60
252+ include_tags = true
253+ }
254+ `
255+
194256func destroyHelper (s * terraform.State , client * datadog.Client ) error {
195257 for _ , r := range s .RootModule ().Resources {
196258 i , _ := strconv .Atoi (r .Primary .ID )
0 commit comments