From f97b6471385bbef4b82357e1326def6db03cf963 Mon Sep 17 00:00:00 2001 From: Vladyslav Mihun Date: Tue, 30 Jan 2024 17:10:41 +0200 Subject: [PATCH] SCALRCORE-29700 Slack integration - separate events for dry and apply runs --- slack_integration.go | 3 +++ slack_integration_test.go | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/slack_integration.go b/slack_integration.go index badc9cb..117cddf 100644 --- a/slack_integration.go +++ b/slack_integration.go @@ -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"` @@ -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"` @@ -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"` diff --git a/slack_integration_test.go b/slack_integration_test.go index 5fc879e..54722ff 100644 --- a/slack_integration_test.go +++ b/slack_integration_test.go @@ -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) { @@ -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}, @@ -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) @@ -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) @@ -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) } })