Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update changelog convert format to include Change Type #209

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tools/cli/internal/cli/changelog/convert/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions tools/cli/internal/cli/changelog/convert/slack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestNewAttachmentText(t *testing.T) {
path string
changeCode string
change string
backwardCompatible string
changeType string
hiddenFromChangelog string
expected string
}{
Expand All @@ -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",
Expand All @@ -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)
})
}
Expand Down
Loading