1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-15 01:34:21 +02:00

fix: only fail announcing phase in the end (#3666)

This prevents one announce failure to skip all other announcers.

The release will still report a failure in the end, but will not fail in
the first failure.

Also improved errors messages a little bit.

closes #3663

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2022-12-28 12:24:21 -03:00
committed by GitHub
parent 1d2842c419
commit 47ce9a9b33
27 changed files with 158 additions and 88 deletions

View File

@ -1,11 +1,13 @@
package errhandler
import (
"errors"
"fmt"
"testing"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/hashicorp/go-multierror"
"github.com/stretchr/testify/require"
)
@ -28,3 +30,29 @@ func TestError(t *testing.T) {
})(nil))
})
}
func TestErrorMemo(t *testing.T) {
memo := Memo{}
t.Run("no errors", func(t *testing.T) {
require.NoError(t, memo.Wrap(func(ctx *context.Context) error {
return nil
})(nil))
})
t.Run("pipe skipped", func(t *testing.T) {
require.NoError(t, memo.Wrap(func(ctx *context.Context) error {
return pipe.ErrSkipValidateEnabled
})(nil))
})
t.Run("some err", func(t *testing.T) {
require.NoError(t, memo.Wrap(func(ctx *context.Context) error {
return fmt.Errorf("pipe errored")
})(nil))
})
err := memo.Error()
merr := &multierror.Error{}
require.True(t, errors.As(err, &merr), "must be a multierror")
require.Len(t, merr.Errors, 1)
}