1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-09 13:36:56 +02:00

chore: added more tests

Added a test covering the cases of wrong regexps.

refs #284
This commit is contained in:
Carlos Alexandro Becker 2017-10-18 00:37:03 -02:00 committed by Carlos Alexandro Becker
parent 28c16f206c
commit 9dcd8e39bd
2 changed files with 22 additions and 3 deletions

View File

@ -9,7 +9,6 @@ import (
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/git"
"github.com/goreleaser/goreleaser/pipeline"
"github.com/pkg/errors"
)
// Pipe for checksums
@ -36,7 +35,7 @@ func (Pipe) Run(ctx *context.Context) error {
for _, filter := range ctx.Config.Changelog.Filters.Exclude {
r, err := regexp.Compile(filter)
if err != nil {
return errors.Wrapf(err, "couldn't compile regexp %s", filter)
return err
}
entries = remove(r, entries)
}

View File

@ -55,7 +55,6 @@ func TestChangelog(t *testing.T) {
})
ctx.Git.CurrentTag = "v0.0.2"
assert.NoError(t, Pipe{}.Run(ctx))
assert.Equal(t, "v0.0.2", ctx.Git.CurrentTag)
assert.Contains(t, ctx.ReleaseNotes, "## Changelog")
assert.NotContains(t, ctx.ReleaseNotes, "first")
assert.Contains(t, ctx.ReleaseNotes, "added feature 1")
@ -89,6 +88,27 @@ func TestChangelogOfFirstRelease(t *testing.T) {
}
}
func TestChangelogFilterInvalidRegex(t *testing.T) {
_, back := testlib.Mktmp(t)
defer back()
testlib.GitInit(t)
testlib.GitCommit(t, "commitssss")
testlib.GitTag(t, "v0.0.3")
testlib.GitCommit(t, "commitzzz")
testlib.GitTag(t, "v0.0.4")
var ctx = context.New(config.Project{
Changelog: config.Changelog{
Filters: config.Filters{
Exclude: []string{
"(?iasdr4qasd)not a valid regex i guess",
},
},
},
})
ctx.Git.CurrentTag = "v0.0.4"
assert.EqualError(t, Pipe{}.Run(ctx), "error parsing regexp: invalid or unsupported Perl syntax: `(?ia`")
}
func TestChangelogNoTags(t *testing.T) {
_, back := testlib.Mktmp(t)
defer back()