Skip to content

Commit

Permalink
reviewer feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mollystamos123 committed Nov 5, 2024
1 parent 66dcb22 commit 2224b64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 4 additions & 0 deletions docs/resources/burn_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ variable "slo_id" {
resource "honeycombio_burn_alert" "example_alert" {
alert_type = "exhaustion_time"
exhaustion_minutes = 480
description = "Exhaustion burn alert description"
dataset = var.dataset
slo_id = var.slo_id
Expand Down Expand Up @@ -51,6 +52,7 @@ resource "honeycombio_burn_alert" "example_alert" {
alert_type = "budget_rate"
budget_rate_window_minutes = 480
budget_rate_decrease_percent = 1
description = "Budget rate burn alert description"
dataset = var.dataset
slo_id = var.slo_id
Expand Down Expand Up @@ -84,6 +86,7 @@ data "honeycombio_recipient" "pd_prod" {
resource "honeycombio_burn_alert" "example_alert" {
exhaustion_minutes = 60
description = "Burn alert description"
dataset = var.dataset
slo_id = var.slo_id
Expand All @@ -103,6 +106,7 @@ resource "honeycombio_burn_alert" "example_alert" {
The following arguments are supported:
* `slo_id` - (Required) ID of the SLO this burn alert is associated with.
* `dataset` - (Required) The dataset this burn alert is associated with.
* `description` - (Optional) Instructions on how to respond to the burn alert, e.g. run book link, next steps.
* `alert_type` - (Optional) Type of the burn alert. Valid values are `exhaustion_time` and `budget_rate`.
Defaults to `exhaustion_time`.
* `budget_rate_window_minutes` - (Optional) The time period, in minutes, over which a budget rate will be calculated.
Expand Down
24 changes: 9 additions & 15 deletions internal/provider/burn_alert_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/honeycombio/terraform-provider-honeycombio/client"
)

const baDescription = "burn alert description"
const testBADescription = "burn alert description"

func TestAcc_BurnAlertResource_defaultBasic(t *testing.T) {
dataset, sloID := burnAlertAccTestSetup(t)
Expand Down Expand Up @@ -484,7 +484,6 @@ func TestAcc_BurnAlertResource_HandlesDynamicRecipientBlock(t *testing.T) {

// Checks that the exhaustion time burn alert exists, has the correct attributes, and has the correct state
func testAccEnsureSuccessExhaustionTimeAlert(t *testing.T, burnAlert *client.BurnAlert, exhaustionMinutes int, pagerdutySeverity, sloID string) resource.TestCheckFunc {

return resource.ComposeAggregateTestCheckFunc(
// Check that the burn alert exists
testAccEnsureBurnAlertExists(t, "honeycombio_burn_alert.test", burnAlert),
Expand All @@ -494,7 +493,7 @@ func testAccEnsureSuccessExhaustionTimeAlert(t *testing.T, burnAlert *client.Bur

// Check that the burn alert has the correct values in state
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "slo_id", sloID),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "description", baDescription),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "description", testBADescription),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "alert_type", "exhaustion_time"),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "exhaustion_minutes", fmt.Sprintf("%d", exhaustionMinutes)),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "recipient.#", "1"),
Expand All @@ -518,7 +517,7 @@ func testAccEnsureSuccessBudgetRateAlert(t *testing.T, burnAlert *client.BurnAle

// Check that the burn alert has the correct values in state
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "slo_id", sloID),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "description", baDescription),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "description", testBADescription),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "alert_type", "budget_rate"),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "budget_rate_window_minutes", fmt.Sprintf("%d", budgetRateWindowMinutes)),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "budget_rate_decrease_percent", helper.FloatToPercentString(budgetRateDecreasePercent)),
Expand Down Expand Up @@ -578,10 +577,6 @@ func testAccEnsureAttributesCorrectBudgetRate(burnAlert *client.BurnAlert, budge
return fmt.Errorf("incorrect alert_type: %s", burnAlert.AlertType)
}

if burnAlert.Description != baDescription {
return fmt.Errorf("incorrect description: %s", burnAlert.Description)
}

if burnAlert.BudgetRateWindowMinutes == nil {
return fmt.Errorf("incorrect budget_rate_window_minutes: expected not to be nil")
}
Expand Down Expand Up @@ -672,7 +667,6 @@ resource "honeycombio_burn_alert" "test" {
dataset = "%[2]s"
slo_id = "%[3]s"
recipient {
id = honeycombio_pagerduty_recipient.test.id
Expand Down Expand Up @@ -704,7 +698,7 @@ resource "honeycombio_burn_alert" "test" {
pagerduty_severity = "%[4]s"
}
}
}`, exhaustionMinutes, dataset, sloID, pdseverity, baDescription)
}`, exhaustionMinutes, dataset, sloID, pdseverity, testBADescription)
}

func testAccConfigBurnAlertDefault_validateAttributesWhenAlertTypeIsExhaustionTime(dataset, sloID string) string {
Expand Down Expand Up @@ -745,7 +739,7 @@ resource "honeycombio_burn_alert" "test" {
pagerduty_severity = "%[4]s"
}
}
}`, exhaustionMinutes, dataset, sloID, pdseverity, baDescription)
}`, exhaustionMinutes, dataset, sloID, pdseverity, testBADescription)
}

func testAccConfigBurnAlertExhaustionTime_validateAttributesWhenAlertTypeIsExhaustionTime(dataset, sloID string) string {
Expand Down Expand Up @@ -788,7 +782,7 @@ resource "honeycombio_burn_alert" "test" {
pagerduty_severity = "%[5]s"
}
}
}`, budgetRateWindowMinutes, helper.FloatToPercentString(budgetRateDecreasePercent), dataset, sloID, pdseverity, baDescription)
}`, budgetRateWindowMinutes, helper.FloatToPercentString(budgetRateDecreasePercent), dataset, sloID, pdseverity, testBADescription)
}

func testAccConfigBurnAlertBudgetRate_trailingZeros(dataset, sloID string) string {
Expand All @@ -814,7 +808,7 @@ resource "honeycombio_burn_alert" "test" {
pagerduty_severity = "info"
}
}
}`, dataset, sloID, baDescription)
}`, dataset, sloID, testBADescription)
}

func testAccConfigBurnAlertBudgetRate_validateAttributesWhenAlertTypeIsBudgetRate(dataset, sloID string) string {
Expand Down Expand Up @@ -859,7 +853,7 @@ resource "honeycombio_burn_alert" "test" {
pagerduty_severity = "info"
}
}
}`, dataset, sloID, baDescription)
}`, dataset, sloID, testBADescription)
}

func testAccConfigBurnAlertWithSlackRecipient(dataset, sloID, channel string) string {
Expand All @@ -875,7 +869,7 @@ resource "honeycombio_burn_alert" "test" {
type = "slack"
target = "%[3]s"
}
}`, dataset, sloID, channel, baDescription)
}`, dataset, sloID, channel, testBADescription)
}

func testAccConfigBurnAlertWithDynamicRecipient(dataset, sloID string) string {
Expand Down

0 comments on commit 2224b64

Please sign in to comment.