Skip to content

Commit

Permalink
SCALRCORE-29700 Slack integration - separate events for dry and apply…
Browse files Browse the repository at this point in the history
… runs
  • Loading branch information
DayS1eeper committed Jan 30, 2024
1 parent 28d0d1f commit f97b647
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions slack_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type SlackIntegration struct {
Status IntegrationStatus `jsonapi:"attr,status"`
ChannelId string `jsonapi:"attr,channel-id"`
Events []string `jsonapi:"attr,events"`
RunMode string `jsonapi:"attr,run-mode"`

// Relations
Account *Account `jsonapi:"relation,account"`
Expand Down Expand Up @@ -70,6 +71,7 @@ type SlackIntegrationCreateOptions struct {
Name *string `jsonapi:"attr,name"`
ChannelId *string `jsonapi:"attr,channel-id"`
Events []string `jsonapi:"attr,events"`
RunMode *string `jsonapi:"attr,run-mode"`

Account *Account `jsonapi:"relation,account"`
Connection *SlackConnection `jsonapi:"relation,connection"`
Expand All @@ -83,6 +85,7 @@ type SlackIntegrationUpdateOptions struct {
ChannelId *string `jsonapi:"attr,channel-id,omitempty"`
Status *IntegrationStatus `jsonapi:"attr,status,omitempty"`
Events []string `jsonapi:"attr,events,omitempty"`
RunMode *string `jsonapi:"attr,run-mode,omitempty"`

Environments []*Environment `jsonapi:"relation,environments,omitempty"`
Workspaces []*Workspace `jsonapi:"relation,workspaces"`
Expand Down
7 changes: 6 additions & 1 deletion slack_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package scalr

import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestSlackIntegrationsCreate(t *testing.T) {
Expand All @@ -30,6 +31,7 @@ func TestSlackIntegrationsCreate(t *testing.T) {
SlackIntegrationEventRunErrored,
},
ChannelId: String("C123"),
RunMode: String("apply"),
Account: &Account{ID: defaultAccountID},
Connection: slackConnection,
Environments: []*Environment{env1},
Expand All @@ -50,6 +52,7 @@ func TestSlackIntegrationsCreate(t *testing.T) {
assert.Equal(t, options.Account, item.Account)
assert.Equal(t, *options.ChannelId, item.ChannelId)
assert.Equal(t, options.Events, item.Events)
assert.Equal(t, *options.RunMode, item.RunMode)
}

err = client.SlackIntegrations.Delete(ctx, si.ID)
Expand Down Expand Up @@ -81,6 +84,7 @@ func TestSlackIntegrationsUpdate(t *testing.T) {
Name: String("test-" + randomString(t)),
Events: []string{SlackIntegrationEventRunApprovalRequired, SlackIntegrationEventRunErrored},
Environments: []*Environment{env2},
RunMode: String("dry"),
}

si, err := client.SlackIntegrations.Update(ctx, si.ID, options)
Expand All @@ -95,6 +99,7 @@ func TestSlackIntegrationsUpdate(t *testing.T) {
} {
assert.NotEmpty(t, item.ID)
assert.Equal(t, *options.Name, item.Name)
assert.Equal(t, *options.RunMode, item.RunMode)
assert.Equal(t, options.Events, item.Events)
}
})
Expand Down

0 comments on commit f97b647

Please sign in to comment.