1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00
goreleaser/internal/pipe/pipe_test.go
Oleksandr Redko 305663fb5d
test: simplify error asserts with require.ErrorContains (#4640)
The PR refactors tests:
- change two lines `require.Error + require.Contains` with one
`require.ErrorContains`;
- change `require.Error + require.Equal` with `require.EqualError`.
2024-02-19 16:28:06 -03:00

35 lines
712 B
Go

package pipe
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestSkipPipe(t *testing.T) {
reason := "this is a test"
err := Skip(reason)
require.EqualError(t, err, reason)
}
func TestIsSkip(t *testing.T) {
require.True(t, IsSkip(Skip("whatever")))
require.False(t, IsSkip(errors.New("nope")))
}
func TestSkipMemento(t *testing.T) {
m := SkipMemento{}
m.Remember(Skip("foo"))
m.Remember(Skip("bar"))
// test duplicated errors
m.Remember(Skip("dupe"))
m.Remember(Skip("dupe"))
require.EqualError(t, m.Evaluate(), `foo, bar, dupe`)
require.True(t, IsSkip(m.Evaluate()))
}
func TestSkipMementoNoErrors(t *testing.T) {
require.NoError(t, (&SkipMemento{}).Evaluate())
}