mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
f544c5ce69
alternative to #3806 the idea is that both `context.New` and `context.Context{}` are never used in tests. not sure yet how much I like it, so far code does look a bit more readable though. --------- Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
32 lines
749 B
Go
32 lines
749 B
Go
package semver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/testctx"
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDescription(t *testing.T) {
|
|
require.NotEmpty(t, Pipe{}.String())
|
|
}
|
|
|
|
func TestValidSemver(t *testing.T) {
|
|
ctx := testctx.New(testctx.WithCurrentTag("v1.5.2-rc1"))
|
|
require.NoError(t, Pipe{}.Run(ctx))
|
|
require.Equal(t, context.Semver{
|
|
Major: 1,
|
|
Minor: 5,
|
|
Patch: 2,
|
|
Prerelease: "rc1",
|
|
}, ctx.Semver)
|
|
}
|
|
|
|
func TestInvalidSemver(t *testing.T) {
|
|
ctx := testctx.New(testctx.WithCurrentTag("aaaav1.5.2-rc1"))
|
|
err := Pipe{}.Run(ctx)
|
|
require.Error(t, err)
|
|
require.Contains(t, err.Error(), "failed to parse tag 'aaaav1.5.2-rc1' as semver")
|
|
}
|