Skip to content

Commit

Permalink
Add Microsoft Teams notification type
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSpiker committed Jun 7, 2022
1 parent 50cc1a8 commit 5e3c27b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
12 changes: 8 additions & 4 deletions notification_configuration.go
Expand Up @@ -59,9 +59,10 @@ type NotificationDestinationType string

// List of available notification destination types.
const (
NotificationDestinationTypeEmail NotificationDestinationType = "email"
NotificationDestinationTypeGeneric NotificationDestinationType = "generic"
NotificationDestinationTypeSlack NotificationDestinationType = "slack"
NotificationDestinationTypeEmail NotificationDestinationType = "email"
NotificationDestinationTypeGeneric NotificationDestinationType = "generic"
NotificationDestinationTypeSlack NotificationDestinationType = "slack"
NotificationDestinationTypeMicrosoftTeams NotificationDestinationType = "microsoft-teams"
)

// NotificationConfigurationList represents a list of Notification
Expand Down Expand Up @@ -319,7 +320,10 @@ func (o NotificationConfigurationCreateOptions) valid() error {
return ErrInvalidNotificationTrigger
}

if *o.DestinationType == NotificationDestinationTypeGeneric || *o.DestinationType == NotificationDestinationTypeSlack {
if *o.DestinationType == NotificationDestinationTypeGeneric ||
*o.DestinationType == NotificationDestinationTypeSlack ||
*o.DestinationType == NotificationDestinationTypeMicrosoftTeams {

if o.URL == nil {
return ErrRequiredURL
}
Expand Down
26 changes: 26 additions & 0 deletions notification_configuration_integration_test.go
Expand Up @@ -128,6 +128,32 @@ func TestNotificationConfigurationCreate(t *testing.T) {
assert.Equal(t, err, ErrRequiredURL)
})

t.Run("without a required value URL when destination type is slack", func(t *testing.T) {
options := NotificationConfigurationCreateOptions{
DestinationType: NotificationDestination(NotificationDestinationTypeSlack),
Enabled: Bool(false),
Name: String(randomString(t)),
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
}

nc, err := client.NotificationConfigurations.Create(ctx, wTest.ID, options)
assert.Nil(t, nc)
assert.Equal(t, err, ErrRequiredURL)
})

t.Run("without a required value URL when destination type is MS Teams", func(t *testing.T) {
options := NotificationConfigurationCreateOptions{
DestinationType: NotificationDestination(NotificationDestinationTypeMicrosoftTeams),
Enabled: Bool(false),
Name: String(randomString(t)),
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
}

nc, err := client.NotificationConfigurations.Create(ctx, wTest.ID, options)
assert.Nil(t, nc)
assert.Equal(t, err, ErrRequiredURL)
})

t.Run("without a valid workspace", func(t *testing.T) {
nc, err := client.NotificationConfigurations.Create(ctx, badIdentifier, NotificationConfigurationCreateOptions{})
assert.Nil(t, nc)
Expand Down

0 comments on commit 5e3c27b

Please sign in to comment.