Skip to content

Commit

Permalink
add test for changing trigger recipient ids
Browse files Browse the repository at this point in the history
A quick attempt to add an acceptance test for changing the recipient ids
of a `honeycombio_trigger` to reproduce honeycombio#267.

Since I don't have a fully clean slate to work with (recipients and
other global objects are shared in my org's Honeycomb API access), I
can't be sure if this failure is accidental or demonstrates the problem
in honeycombio#267.

It currently fails on my machine in a special environment and dataset just for it with:

```
$  TF_ACC=1 go test -v -run=TestAccHoneycombIOTrigger_changingRecipientID ./...
?   	github.com/honeycombio/terraform-provider-honeycombio	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/honeycombio/terraform-provider-honeycombio/client	(cached) [no tests to run]
?   	github.com/honeycombio/terraform-provider-honeycombio/client/internal/httputil	[no test files]
=== RUN   TestAccHoneycombIOTrigger_changingRecipientID
    resource_trigger_test.go:213: Step 2/2 error: Check failed: honeycombio_trigger.test: Attribute 'recipient.0.id' expected "xmbNbyhSY91", got "rX2sUPHwbjn"
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: exit status 1

        Error: 409 Conflict: Recipient rX2sUPHwbjn is being used by a trigger or burn alert and cannot be deleted

--- FAIL: TestAccHoneycombIOTrigger_changingRecipientID (4.38s)
FAIL
FAIL	github.com/honeycombio/terraform-provider-honeycombio/honeycombio	4.703s
?   	github.com/honeycombio/terraform-provider-honeycombio/honeycombio/internal/hashcode	[no test files]
?   	github.com/honeycombio/terraform-provider-honeycombio/honeycombio/internal/verify	[no test files]
FAIL

```
  • Loading branch information
jmhodges-color committed Feb 3, 2023
1 parent 24aa653 commit b63fd2a
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions honeycombio/resource_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,68 @@ resource "honeycombio_trigger" "test" {
})
}

func TestAccHoneycombIOTrigger_changingRecipientID(t *testing.T) {
dataset := testAccDataset()

// test changing the recipient id
resource.Test(t, resource.TestCase{
PreCheck: testAccPreCheck(t),
ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccChangingRecipientID(dataset, "honeycombio_slack_recipient.test1"),
Check: resource.TestCheckResourceAttrPair("honeycombio_trigger.test", "recipient.0.id", "honeycombio_slack_recipient.test1", "id"),
},
{
Config: testAccChangingRecipientID(dataset, "honeycombio_pagerduty_recipient.test2"),
Check: resource.TestCheckResourceAttrPair("honeycombio_trigger.test", "recipient.0.id", "honeycombio_pagerduty_recipient.test2", "id"),
},
},
})
}

func testAccChangingRecipientID(dataset, recipientName string) string {
return fmt.Sprintf(`
data "honeycombio_query_specification" "test" {
calculation {
op = "AVG"
column = "duration_ms"
}
time_range = 1800
}
resource "honeycombio_query" "test" {
dataset = "%s"
query_json = data.honeycombio_query_specification.test.json
}
resource "honeycombio_slack_recipient" "test1" {
channel = "#alerty-alerts"
}
resource "honeycombio_pagerduty_recipient" "test2" {
integration_key = "09c9d4cacd68933151a1ef1048b67dd5"
integration_name = "acctest"
}
resource "honeycombio_trigger" "test" {
name = "Test trigger with changing recipient id"
dataset = "%s"
query_id = honeycombio_query.test.id
threshold {
op = ">"
value = 100
}
recipient {
id = %s.id
}
}`, dataset, dataset, recipientName)
}

func TestAccHoneycombioTrigger_recipientOrderingNoDiff(t *testing.T) {
dataset := testAccDataset()

Expand Down

0 comments on commit b63fd2a

Please sign in to comment.