1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/internal/pipe/semver/semver_test.go
Carlos Alexandro Becker 833db79bda
feat: removes deprecated non-semver allowance (#2503)
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2021-09-23 00:39:28 -03:00

34 lines
773 B
Go

package semver
import (
"testing"
"github.com/goreleaser/goreleaser/pkg/config"
"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 := context.New(config.Project{})
ctx.Git.CurrentTag = "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 := context.New(config.Project{})
ctx.Git.CurrentTag = "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")
}