Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
brookesargent committed Jan 7, 2025
1 parent 88c4c0b commit 8f009fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/helper/validation/valid_notification_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func (v notificationVariablesValidator) ValidateSet(ctx context.Context, request
}
}

// ValidQuerySpec determines if the provided JSON is a valid Honeycomb Query Specification
// ValidNotificationVariables determines if the provided recipient notification variables are valid.
// Today this means no variable names are duplicated.
func ValidNotificationVariables() validator.Set {
return notificationVariablesValidator{}
}
8 changes: 4 additions & 4 deletions internal/provider/notification_recipients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Test_reconcileReadNotificationRecipientState(t *testing.T) {
ID: types.StringValue("ijkl13579"),
Type: types.StringValue("pagerduty"),
Target: types.StringValue("test-pagerduty"),
Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, severityStringToValue("warning")),
Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, notificationRecipientDetailsToValue("warning")),
},
}),
},
Expand All @@ -109,7 +109,7 @@ func Test_reconcileReadNotificationRecipientState(t *testing.T) {
state: notificationRecipientModelsToSet([]models.NotificationRecipientModel{
{ID: types.StringValue("abcd12345")},
{Type: types.StringValue("slack"), Target: types.StringValue("#test-foo")},
{ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, severityStringToValue("warning"))},
{ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, notificationRecipientDetailsToValue("warning"))},
}),
},
want: notificationRecipientModelsToSet([]models.NotificationRecipientModel{
Expand All @@ -125,7 +125,7 @@ func Test_reconcileReadNotificationRecipientState(t *testing.T) {
state: notificationRecipientModelsToSet([]models.NotificationRecipientModel{
{ID: types.StringValue("abcd12345")},
{Type: types.StringValue("slack"), Target: types.StringValue("#test-channel")},
{ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, severityStringToValue("warning"))},
{ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, notificationRecipientDetailsToValue("warning"))},
}),
},
want: notificationRecipientModelsToSet([]models.NotificationRecipientModel{
Expand All @@ -149,6 +149,6 @@ func notificationRecipientModelsToSet(n []models.NotificationRecipientModel) typ
return types.SetValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}, values)
}

func severityStringToValue(s string) []attr.Value {
func notificationRecipientDetailsToValue(s string) []attr.Value {
return []attr.Value{types.ObjectValueMust(models.NotificationRecipientDetailsAttrType, map[string]attr.Value{"pagerduty_severity": types.StringValue(s), "variable": types.SetNull(types.ObjectType{AttrTypes: models.NotificationVariableAttrType})})}
}

0 comments on commit 8f009fa

Please sign in to comment.