From af873b04c8d3cf38c367a5e1c5f9e2a60c1b1cf0 Mon Sep 17 00:00:00 2001 From: brookesargent Date: Mon, 25 Nov 2024 09:01:35 -0500 Subject: [PATCH] remove variable test passing --- client/recipient.go | 2 +- .../provider/webhook_recipient_resource.go | 2 + .../webhook_recipient_resource_test.go | 76 +++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/client/recipient.go b/client/recipient.go index c78111f6..eb4723ef 100644 --- a/client/recipient.go +++ b/client/recipient.go @@ -76,7 +76,7 @@ type NotificationRecipientDetails struct { type WebhookPayloads struct { PayloadTemplates PayloadTemplates `json:"payload_templates"` - TemplateVariables []TemplateVariable `json:"template_variables,omitempty"` + TemplateVariables []TemplateVariable `json:"template_variables"` } type PayloadTemplates struct { diff --git a/internal/provider/webhook_recipient_resource.go b/internal/provider/webhook_recipient_resource.go index fd3474a3..5184f124 100644 --- a/internal/provider/webhook_recipient_resource.go +++ b/internal/provider/webhook_recipient_resource.go @@ -298,6 +298,8 @@ func (r *webhookRecipientResource) Update(ctx context.Context, req resource.Upda state.Templates = plan.Templates if rcpt.Details.WebhookPayloads.TemplateVariables != nil { state.Variables = plan.Variables + } else { + state.Variables = types.SetNull(types.ObjectType{AttrTypes: models.TemplateVariableAttrType}) } } else { state.Templates = types.SetNull(types.ObjectType{AttrTypes: models.WebhookTemplateAttrType}) diff --git a/internal/provider/webhook_recipient_resource_test.go b/internal/provider/webhook_recipient_resource_test.go index ae497d13..6f64fb05 100644 --- a/internal/provider/webhook_recipient_resource_test.go +++ b/internal/provider/webhook_recipient_resource_test.go @@ -302,6 +302,82 @@ resource "honeycombio_webhook_recipient" "test" { }) }) + t.Run("custom webhook when a variable is removed", func(t *testing.T) { + name := test.RandomStringWithPrefix("test.", 20) + url := test.RandomURL() + body := `<