Skip to content

Commit

Permalink
Add notification rule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-futurice committed Jul 29, 2024
1 parent 5c75248 commit 2d84045
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func DTPublisherToTFPublisher(ctx context.Context, dtPublisher dtrack.Notificati
Template: types.StringValue(dtPublisher.Template),
}

// normalize the description to null to allow the attribute to be optional
// normalize to null to allow the attribute to be optional
if len(dtPublisher.Description) > 0 {
publisher.Description = types.StringValue(dtPublisher.Description)
} else {
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/notificationrule/notification_rule_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (r *NotificationRuleResource) Schema(ctx context.Context, req resource.Sche
"scope": schema.StringAttribute{
MarkdownDescription: "Rule scope. Possible values: [PORTFOLIO, SYSTEM]",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"notification_level": schema.StringAttribute{
MarkdownDescription: "Notification level. Possible values: [INFORMATIONAL, WARNING, ERROR]",
Expand Down Expand Up @@ -266,6 +269,13 @@ func DTRuleToTFRule(ctx context.Context, dtRule dtrack.NotificationRule) (Notifi
PublisherConfig: types.StringValue(dtRule.PublisherConfig),
}

// normalize to null to allow the attribute to be optional
if len(dtRule.PublisherConfig) > 0 {
rule.PublisherConfig = types.StringValue(dtRule.PublisherConfig)
} else {
rule.PublisherConfig = types.StringNull()
}

rule.NotifyOn, diags = types.SetValueFrom(ctx, types.StringType, dtRule.NotifyOn)

return rule, diags
Expand Down
Loading

0 comments on commit 2d84045

Please sign in to comment.