2018-02-17 13:43:29 -02:00
|
|
|
package deprecate
|
|
|
|
|
|
|
|
import (
|
2021-03-01 14:18:57 -03:00
|
|
|
"bytes"
|
2018-02-17 13:43:29 -02:00
|
|
|
"testing"
|
|
|
|
|
2022-06-21 21:11:15 -03:00
|
|
|
"github.com/caarlos0/log"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
2021-05-30 21:53:40 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/golden"
|
2020-04-12 14:31:35 -03:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2022-06-21 21:11:15 -03:00
|
|
|
"github.com/muesli/termenv"
|
2018-10-27 12:59:42 -03:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-02-17 13:43:29 -02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNotice(t *testing.T) {
|
2022-06-21 21:11:15 -03:00
|
|
|
lipgloss.SetColorProfile(termenv.Ascii)
|
2018-10-27 13:27:09 -03:00
|
|
|
|
2022-06-21 21:11:15 -03:00
|
|
|
var w bytes.Buffer
|
|
|
|
log.Log = log.New(&w)
|
2018-10-27 12:59:42 -03:00
|
|
|
|
2018-02-17 13:43:29 -02:00
|
|
|
log.Info("first")
|
2021-03-01 14:18:57 -03:00
|
|
|
ctx := context.New(config.Project{})
|
2022-03-17 07:55:17 -03:00
|
|
|
Notice(ctx, "foo.bar.whatever: foobar")
|
2018-02-17 13:43:29 -02:00
|
|
|
log.Info("last")
|
2020-04-12 14:31:35 -03:00
|
|
|
require.True(t, ctx.Deprecated)
|
2018-02-17 13:43:29 -02:00
|
|
|
|
2021-05-30 21:53:40 -03:00
|
|
|
golden.RequireEqualTxt(t, w.Bytes())
|
2021-03-01 14:18:57 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestNoticeCustom(t *testing.T) {
|
2022-06-21 21:11:15 -03:00
|
|
|
lipgloss.SetColorProfile(termenv.Ascii)
|
2021-03-01 14:18:57 -03:00
|
|
|
|
2022-06-21 21:11:15 -03:00
|
|
|
var w bytes.Buffer
|
|
|
|
log.Log = log.New(&w)
|
2021-03-01 14:18:57 -03:00
|
|
|
|
|
|
|
log.Info("first")
|
|
|
|
ctx := context.New(config.Project{})
|
|
|
|
NoticeCustom(ctx, "something-else", "some custom template with a url {{ .URL }}")
|
|
|
|
log.Info("last")
|
|
|
|
require.True(t, ctx.Deprecated)
|
|
|
|
|
2021-05-30 21:53:40 -03:00
|
|
|
golden.RequireEqualTxt(t, w.Bytes())
|
2018-02-17 13:43:29 -02:00
|
|
|
}
|