diff --git a/tools/cli/internal/cli/changelog/convert/slack.go b/tools/cli/internal/cli/changelog/convert/slack.go index 92d1f9e31..0dc2554ff 100644 --- a/tools/cli/internal/cli/changelog/convert/slack.go +++ b/tools/cli/internal/cli/changelog/convert/slack.go @@ -133,25 +133,25 @@ func orderAttachments(attachments []*Attachment) []*Attachment { func newAttachmentFromVersion(path *changelog.Path, version *changelog.Version) []*Attachment { attachments := make([]*Attachment, 0) for _, change := range version.Changes { - attachments = append(attachments, newAttachmentFromChange(version.Version, path.HTTPMethod, path.URI, change)) + attachments = append(attachments, newAttachmentFromChange(version.Version, path.HTTPMethod, path.URI, path.ChangeType, change)) } return attachments } -func newAttachmentFromChange(version, method, path string, change *changelog.Change) *Attachment { +func newAttachmentFromChange(version, method, path, changeType string, change *changelog.Change) *Attachment { return &Attachment{ - Text: newAttachmentText(version, method, path, change.Code, change.Description, strconv.FormatBool(change.BackwardCompatible), + Text: newAttachmentText(version, method, path, changeType, change.Code, change.Description, strconv.FormatBool(change.HideFromChangelog)), Color: newColorFromBackwardCompatible(change.BackwardCompatible), AttachmentType: attachmentTypeDefault, } } -func newAttachmentText(version, method, path, changeCode, change, backwardCompatible, hiddenFromChangelog string) string { +func newAttachmentText(version, method, path, changeType, changeCode, change, hiddenFromChangelog string) string { return fmt.Sprintf( - "\n• *Version*: `%s`\n• *Path*: `%s %s`\n• *Hidden from Changelog*: `%s`\n• *Change Code*: `%s`\n• *Change*: `%s`\n• *Backward Compatible*: `%s`", - version, method, path, hiddenFromChangelog, changeCode, change, backwardCompatible) + "\n• *Version*: `%s` | *Hidden from Changelog*: `%s`\n• *Path*: `%s %s`\n• *Change Type*: `%s` | *Change Code*: `%s`\n• *Change*: `%s`", + version, hiddenFromChangelog, method, path, changeType, changeCode, change) } func newColorFromBackwardCompatible(backwardCompatible bool) string { diff --git a/tools/cli/internal/cli/changelog/convert/slack_test.go b/tools/cli/internal/cli/changelog/convert/slack_test.go index 2ee7659d0..2674be9a3 100644 --- a/tools/cli/internal/cli/changelog/convert/slack_test.go +++ b/tools/cli/internal/cli/changelog/convert/slack_test.go @@ -28,7 +28,7 @@ func TestNewAttachmentText(t *testing.T) { path string changeCode string change string - backwardCompatible string + changeType string hiddenFromChangelog string expected string }{ @@ -39,9 +39,9 @@ func TestNewAttachmentText(t *testing.T) { path: "/api/atlas/v2/groups/{groupId}/clusters", changeCode: "response-property-enum-value-added", change: "added the new DUBLIN_IRL, FRANKFURT_DEU, LONDON_GBR enum values", - backwardCompatible: "true", + changeType: "UPDATE", hiddenFromChangelog: "false", - expected: "\n• *Version*: `2024-08-05`\n• *Path*: `GET /api/atlas/v2/groups/{groupId}/clusters`\n• *Hidden from Changelog*: `false`\n• *Change Code*: `response-property-enum-value-added`\n• *Change*: `added the new DUBLIN_IRL, FRANKFURT_DEU, LONDON_GBR enum values`\n• *Backward Compatible*: `true`", //nolint:lll //Test string + expected: "\n• *Version*: `2024-08-05` | *Hidden from Changelog*: `false`\n• *Path*: `GET /api/atlas/v2/groups/{groupId}/clusters`\n• *Change Type*: `UPDATE` | *Change Code*: `response-property-enum-value-added`\n• *Change*: `added the new DUBLIN_IRL, FRANKFURT_DEU, LONDON_GBR enum values`", //nolint:lll //Test string }, { name: "Non-Backward Compatible Change", @@ -51,14 +51,14 @@ func TestNewAttachmentText(t *testing.T) { changeCode: "new-optional-request-property", change: "added the new optional request property replicaSetScalingStrategy", hiddenFromChangelog: "true", - backwardCompatible: "false", - expected: "\n• *Version*: `2024-08-05`\n• *Path*: `POST /api/atlas/v2/groups/{groupId}/clusters`\n• *Hidden from Changelog*: `true`\n• *Change Code*: `new-optional-request-property`\n• *Change*: `added the new optional request property replicaSetScalingStrategy`\n• *Backward Compatible*: `false`", //nolint:lll //Test string + changeType: "RELEASE", + expected: "\n• *Version*: `2024-08-05` | *Hidden from Changelog*: `true`\n• *Path*: `POST /api/atlas/v2/groups/{groupId}/clusters`\n• *Change Type*: `RELEASE` | *Change Code*: `new-optional-request-property`\n• *Change*: `added the new optional request property replicaSetScalingStrategy`", //nolint:lll //Test string }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - actual := newAttachmentText(tt.version, tt.method, tt.path, tt.changeCode, tt.change, tt.backwardCompatible, tt.hiddenFromChangelog) + actual := newAttachmentText(tt.version, tt.method, tt.path, tt.changeType, tt.changeCode, tt.change, tt.hiddenFromChangelog) assert.Equal(t, tt.expected, actual) }) }