Files
coder/scripts/release/main_test.go
T
Mathias Fredriksson c933c75aa7 chore(scripts): add script to promote mainline to stable (#13054)
Fixes #12459

Example dry-run:

<img width="1229" alt="Screenshot 2024-04-23 at 21 16 55" src="https://github.com/coder/coder/assets/147409/7018d322-501b-41e2-bf47-af3fc39fb3d2">

Example dry-run for non-latest version:

<img width="1228" alt="Screenshot 2024-04-23 at 21 17 52" src="https://github.com/coder/coder/assets/147409/a05fcd44-560f-4e44-81b5-76c071c591b4">

**Note:** This PR does not yet update docs to reflect the promoted version. This will be part of #12465.
2024-04-24 22:59:22 +03:00

137 lines
3.8 KiB
Go

package main
import (
"testing"
"time"
"github.com/google/go-cmp/cmp"
)
func Test_removeMainlineBlurb(t *testing.T) {
t.Parallel()
tests := []struct {
name string
body string
want string
}{
{
name: "NoMainlineBlurb",
body: `## Changelog
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/v2/latest/install) or [upgrade](https://coder.com/docs/v2/latest/admin/upgrade) Coder, or use a release asset below.
`,
want: `## Changelog
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/v2/latest/install) or [upgrade](https://coder.com/docs/v2/latest/admin/upgrade) Coder, or use a release asset below.
`,
},
{
name: "WithMainlineBlurb",
body: `## Changelog
> [!NOTE]
> This is a mainline Coder release. We advise enterprise customers without a staging environment to install our [latest stable release](https://github.com/coder/coder/releases/latest) while we refine this version. Learn more about our [Release Schedule](https://coder.com/docs/v2/latest/install/releases).
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/v2/latest/install) or [upgrade](https://coder.com/docs/v2/latest/admin/upgrade) Coder, or use a release asset below.
`,
want: `## Changelog
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/v2/latest/install) or [upgrade](https://coder.com/docs/v2/latest/admin/upgrade) Coder, or use a release asset below.
`,
},
{
name: "EntireQuotedBlurbIsRemoved",
body: `## Changelog
> [!NOTE]
> This is a mainline Coder release. We advise enterprise customers without a staging environment to install our [latest stable release](https://github.com/coder/coder/releases/latest) while we refine this version. Learn more about our [Release Schedule](https://coder.com/docs/v2/latest/install/releases).
> This is an extended note.
> This is another extended note.
### Best release yet!
Enjoy.
`,
want: `## Changelog
### Best release yet!
Enjoy.
`,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if diff := cmp.Diff(removeMainlineBlurb(tt.body), tt.want); diff != "" {
t.Errorf("removeMainlineBlurb() mismatch (-want +got):\n%s", diff)
}
})
}
}
func Test_addStableSince(t *testing.T) {
t.Parallel()
date := time.Date(2024, time.April, 23, 0, 0, 0, 0, time.UTC)
body := "## Changelog"
expected := "> ## Stable (since April 23, 2024)\n\n## Changelog"
result := addStableSince(date, body)
if diff := cmp.Diff(expected, result); diff != "" {
t.Errorf("addStableSince() mismatch (-want +got):\n%s", diff)
}
}