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:
parent
28c16f206c
commit
9dcd8e39bd
@ -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)
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user