diff --git a/observe/resource_monitor_v2_test.go b/observe/resource_monitor_v2_test.go index 3f32b843..19268139 100644 --- a/observe/resource_monitor_v2_test.go +++ b/observe/resource_monitor_v2_test.go @@ -294,11 +294,99 @@ func TestAccObserveMonitorV2MultipleActionsEmailViaOneShot(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("observe_monitor_v2.first", "workspace"), resource.TestCheckResourceAttr("observe_monitor_v2.first", "name", randomPrefix), + resource.TestCheckResourceAttr("observe_monitor_v2.first", "lookback_time", "30m0s"), resource.TestCheckResourceAttr("observe_monitor_v2.first", "max_alerts_per_hour", "99"), resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.0.action.0.description", "an interesting description 1"), resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.0.action.0.type", "email"), resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.1.action.0.description", "an interesting description 2"), resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.0.action.0.type", "email"), + resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.0.send_reminders_interval", "10m0s"), + resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.1.send_reminders_interval", "20m0s"), + ), + }, + // now test update + { + Config: fmt.Sprintf(monitorV2ConfigPreamble+` + resource "observe_monitor_v2" "first" { + workspace = data.observe_workspace.default.oid + rule_kind = "count" + name = "%[1]s" + lookback_time = "15m" + inputs = { + "test" = observe_datastream.test.dataset + } + stage { + pipeline = <<-EOF + colmake kind:"test", description:"test" + EOF + output_stage = true + } + stage { + pipeline = <<-EOF + filter kind ~ "test" + EOF + } + rules { + level = "informational" + count { + compare_values { + compare_fn = "greater" + value_int64 = [0] + } + } + } + scheduling { + transform { + freshness_goal = "15m" + } + } + max_alerts_per_hour = 99 + actions { + action { + type = "email" + email { + subject = "somebody once told me" + body = "the world is gonna roll me" + fragments = jsonencode({ + foo = "bar" + }) + addresses = ["test@observeinc.com"] + users = [data.observe_user.system.oid] + } + description = "an interesting description 1" + } + levels = ["informational"] + send_end_notifications = true + send_reminders_interval = "11m" + } + actions { + action { + type = "email" + email { + subject = "never gonna give you up" + body = "never gonna let you down" + fragments = jsonencode({ + fizz = "buzz" + }) + addresses = ["test@observeinc.com"] + users = [data.observe_user.system.oid] + } + description = "an interesting description 2" + } + levels = ["informational"] + send_end_notifications = false + send_reminders_interval = "22m" + } + } + + data "observe_user" "system" { + email = "%[2]s" + } + `, randomPrefix, systemUser()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("observe_monitor_v2.first", "lookback_time", "15m0s"), + resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.0.send_reminders_interval", "11m0s"), + resource.TestCheckResourceAttr("observe_monitor_v2.first", "actions.1.send_reminders_interval", "22m0s"), ), }, },