2019-01-19 16:57:58 -02:00
|
|
|
package semver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-02 00:01:11 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/testctx"
|
2019-01-19 16:57:58 -02:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDescription(t *testing.T) {
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NotEmpty(t, Pipe{}.String())
|
2019-01-19 16:57:58 -02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestValidSemver(t *testing.T) {
|
2023-03-02 00:01:11 -03:00
|
|
|
ctx := testctx.New(testctx.WithCurrentTag("v1.5.2-rc1"))
|
2019-01-19 16:57:58 -02:00
|
|
|
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) {
|
2023-03-02 00:01:11 -03:00
|
|
|
ctx := testctx.New(testctx.WithCurrentTag("aaaav1.5.2-rc1"))
|
2021-03-01 14:18:57 -03:00
|
|
|
err := Pipe{}.Run(ctx)
|
2019-01-19 16:57:58 -02:00
|
|
|
require.Error(t, err)
|
2021-03-01 14:18:57 -03:00
|
|
|
require.Contains(t, err.Error(), "failed to parse tag 'aaaav1.5.2-rc1' as semver")
|
2019-01-19 16:57:58 -02:00
|
|
|
}
|