Skip to content

Commit

Permalink
pr: add update test
Browse files Browse the repository at this point in the history
  • Loading branch information
obs-gh-catherman committed Nov 27, 2024
1 parent d3a8c18 commit 220a5aa
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions observe/resource_monitor_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ["[email protected]"]
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 = ["[email protected]"]
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"),
),
},
},
Expand Down

0 comments on commit 220a5aa

Please sign in to comment.