Skip to content

Commit

Permalink
fix(r/burn_alert): handle existing description outside of config
Browse files Browse the repository at this point in the history
  • Loading branch information
jharley committed Nov 15, 2024
1 parent c8084fc commit 2662b5e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions internal/provider/burn_alert_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,48 @@ func TestAcc_BurnAlertResource_HandlesDynamicRecipientBlock(t *testing.T) {
})
}

func TestAcc_BurnAlertResource_HandlesDescriptionSetToEmptyString(t *testing.T) {
ctx := context.Background()
dataset, sloID := burnAlertAccTestSetup(t)
burnAlert := &client.BurnAlert{}

config := fmt.Sprintf(`
resource "honeycombio_burn_alert" "test" {
exhaustion_minutes = 240
dataset = "%s"
slo_id = "%s"
recipient {
type = "email"
target = "%s"
}
}`, dataset, sloID, test.RandomEmail())

resource.Test(t, resource.TestCase{
PreCheck: testAccPreCheck(t),
ProtoV5ProviderFactories: testAccProtoV5MuxServerFactory,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccEnsureBurnAlertExists(t, "honeycombio_burn_alert.test", burnAlert),
resource.TestCheckResourceAttr("honeycombio_burn_alert.test", "description", ""),
),
},
{
PreConfig: func() {
// add a description to the burn alert outside of Terraform
burnAlert.Description = "test description"
_, err := testAccClient(t).BurnAlerts.Update(ctx, dataset, burnAlert)
require.NoError(t, err, "failed to update burn alert")
},
Config: config,
},
},
})
}

// 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(
Expand Down

0 comments on commit 2662b5e

Please sign in to comment.