1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
Carlos Alexandro Becker 4d0c0d2072
feat: release header/footer (#2267)
* feat: release header/footer

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* feat: release header/footer

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* refactor: using the golden library all over

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: lint

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: brew arm tests

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: use footer

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
2021-05-30 21:53:40 -03:00

105 lines
2.7 KiB
Go

package release
import (
"testing"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/golden"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/require"
)
func TestDescribeBody(t *testing.T) {
changelog := "feature1: description\nfeature2: other description"
ctx := context.New(config.Project{})
ctx.ReleaseNotes = changelog
for _, d := range []string{
"goreleaser/goreleaser:0.40.0",
"goreleaser/goreleaser:latest",
"goreleaser/godownloader:v0.1.0",
} {
ctx.Artifacts.Add(&artifact.Artifact{
Name: d,
Type: artifact.DockerImage,
})
}
out, err := describeBody(ctx)
require.NoError(t, err)
golden.RequireEqual(t, out.Bytes())
}
func TestDescribeBodyWithDockerManifest(t *testing.T) {
changelog := "feature1: description\nfeature2: other description"
ctx := context.New(config.Project{})
ctx.ReleaseNotes = changelog
for _, d := range []string{
"goreleaser/goreleaser:0.40.0",
"goreleaser/goreleaser:latest",
"goreleaser/godownloader:v0.1.0",
} {
ctx.Artifacts.Add(&artifact.Artifact{
Name: d,
Type: artifact.DockerManifest,
})
}
for _, d := range []string{
"goreleaser/goreleaser:0.40.0-amd64",
"goreleaser/goreleaser:latest-amd64",
"goreleaser/godownloader:v0.1.0-amd64",
"goreleaser/goreleaser:0.40.0-arm64",
"goreleaser/goreleaser:latest-arm64",
"goreleaser/godownloader:v0.1.0-arm64",
} {
ctx.Artifacts.Add(&artifact.Artifact{
Name: d,
Type: artifact.DockerImage,
})
}
out, err := describeBody(ctx)
require.NoError(t, err)
golden.RequireEqual(t, out.Bytes())
}
func TestDescribeBodyNoDockerImagesNoBrews(t *testing.T) {
changelog := "feature1: description\nfeature2: other description"
ctx := &context.Context{
ReleaseNotes: changelog,
}
out, err := describeBody(ctx)
require.NoError(t, err)
golden.RequireEqual(t, out.Bytes())
}
func TestDontEscapeHTML(t *testing.T) {
changelog := "<h1>test</h1>"
ctx := context.New(config.Project{})
ctx.ReleaseNotes = changelog
out, err := describeBody(ctx)
require.NoError(t, err)
require.Contains(t, out.String(), changelog)
}
func TestDescribeBodyWithHeaderAndFooter(t *testing.T) {
changelog := "feature1: description\nfeature2: other description"
ctx := context.New(config.Project{
Release: config.Release{
Header: "## Yada yada yada\nsomething\n",
Footer: "\n---\n\nGet GoReleaser Pro at https://goreleaser.com/pro",
},
})
ctx.ReleaseNotes = changelog
ctx.Artifacts.Add(&artifact.Artifact{
Name: "goreleaser/goreleaser:latest",
Type: artifact.DockerImage,
})
out, err := describeBody(ctx)
require.NoError(t, err)
golden.RequireEqual(t, out.Bytes())
}