Skip to content

Commit b7881fd

Browse files
committed
Add Microsoft Teams notification type
1 parent 6115330 commit b7881fd

2 files changed

+34
-4
lines changed

notification_configuration.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ type NotificationDestinationType string
5959

6060
// List of available notification destination types.
6161
const (
62-
NotificationDestinationTypeEmail NotificationDestinationType = "email"
63-
NotificationDestinationTypeGeneric NotificationDestinationType = "generic"
64-
NotificationDestinationTypeSlack NotificationDestinationType = "slack"
62+
NotificationDestinationTypeEmail NotificationDestinationType = "email"
63+
NotificationDestinationTypeGeneric NotificationDestinationType = "generic"
64+
NotificationDestinationTypeSlack NotificationDestinationType = "slack"
65+
NotificationDestinationTypeMicrosoftTeams NotificationDestinationType = "microsoft-teams"
6566
)
6667

6768
// NotificationConfigurationList represents a list of Notification
@@ -319,7 +320,10 @@ func (o NotificationConfigurationCreateOptions) valid() error {
319320
return ErrInvalidNotificationTrigger
320321
}
321322

322-
if *o.DestinationType == NotificationDestinationTypeGeneric || *o.DestinationType == NotificationDestinationTypeSlack {
323+
if *o.DestinationType == NotificationDestinationTypeGeneric ||
324+
*o.DestinationType == NotificationDestinationTypeSlack ||
325+
*o.DestinationType == NotificationDestinationTypeMicrosoftTeams {
326+
323327
if o.URL == nil {
324328
return ErrRequiredURL
325329
}

notification_configuration_integration_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,32 @@ func TestNotificationConfigurationCreate(t *testing.T) {
128128
assert.Equal(t, err, ErrRequiredURL)
129129
})
130130

131+
t.Run("without a required value URL when destination type is slack", func(t *testing.T) {
132+
options := NotificationConfigurationCreateOptions{
133+
DestinationType: NotificationDestination(NotificationDestinationTypeSlack),
134+
Enabled: Bool(false),
135+
Name: String(randomString(t)),
136+
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
137+
}
138+
139+
nc, err := client.NotificationConfigurations.Create(ctx, wTest.ID, options)
140+
assert.Nil(t, nc)
141+
assert.Equal(t, err, ErrRequiredURL)
142+
})
143+
144+
t.Run("without a required value URL when destination type is MS Teams", func(t *testing.T) {
145+
options := NotificationConfigurationCreateOptions{
146+
DestinationType: NotificationDestination(NotificationDestinationTypeMicrosoftTeams),
147+
Enabled: Bool(false),
148+
Name: String(randomString(t)),
149+
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
150+
}
151+
152+
nc, err := client.NotificationConfigurations.Create(ctx, wTest.ID, options)
153+
assert.Nil(t, nc)
154+
assert.Equal(t, err, ErrRequiredURL)
155+
})
156+
131157
t.Run("without a valid workspace", func(t *testing.T) {
132158
nc, err := client.NotificationConfigurations.Create(ctx, badIdentifier, NotificationConfigurationCreateOptions{})
133159
assert.Nil(t, nc)

0 commit comments

Comments
 (0)