1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00
goreleaser/internal/deprecate/deprecate_test.go

45 lines
996 B
Go
Raw Normal View History

package deprecate
import (
"bytes"
"testing"
"github.com/caarlos0/log"
"github.com/charmbracelet/lipgloss"
"github.com/goreleaser/goreleaser/internal/golden"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/muesli/termenv"
2018-10-27 12:59:42 -03:00
"github.com/stretchr/testify/require"
)
func TestNotice(t *testing.T) {
lipgloss.SetColorProfile(termenv.Ascii)
2018-10-27 13:27:09 -03:00
var w bytes.Buffer
log.Log = log.New(&w)
2018-10-27 12:59:42 -03:00
log.Info("first")
ctx := context.New(config.Project{})
2022-03-17 07:55:17 -03:00
Notice(ctx, "foo.bar.whatever: foobar")
log.Info("last")
require.True(t, ctx.Deprecated)
golden.RequireEqualTxt(t, w.Bytes())
}
func TestNoticeCustom(t *testing.T) {
lipgloss.SetColorProfile(termenv.Ascii)
var w bytes.Buffer
log.Log = log.New(&w)
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)
golden.RequireEqualTxt(t, w.Bytes())
}