2018-02-17 17:43:29 +02:00
|
|
|
package deprecate
|
|
|
|
|
|
|
|
import (
|
2021-03-01 19:18:57 +02:00
|
|
|
"bytes"
|
2018-02-17 17:43:29 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
|
|
|
"github.com/apex/log/handlers/cli"
|
2018-10-26 23:27:17 +02:00
|
|
|
"github.com/fatih/color"
|
2021-05-31 02:53:40 +02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/golden"
|
2020-04-12 19:31:35 +02:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2018-10-27 17:59:42 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-02-17 17:43:29 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNotice(t *testing.T) {
|
2021-03-01 19:18:57 +02:00
|
|
|
var w bytes.Buffer
|
2018-10-27 18:27:09 +02:00
|
|
|
|
|
|
|
color.NoColor = true
|
2021-03-01 19:18:57 +02:00
|
|
|
log.SetHandler(cli.New(&w))
|
2018-10-27 17:59:42 +02:00
|
|
|
|
2018-02-17 17:43:29 +02:00
|
|
|
log.Info("first")
|
2021-03-01 19:18:57 +02:00
|
|
|
ctx := context.New(config.Project{})
|
2020-04-12 19:31:35 +02:00
|
|
|
Notice(ctx, "foo.bar.whatever")
|
2018-02-17 17:43:29 +02:00
|
|
|
log.Info("last")
|
2020-04-12 19:31:35 +02:00
|
|
|
require.True(t, ctx.Deprecated)
|
2018-02-17 17:43:29 +02:00
|
|
|
|
2021-05-31 02:53:40 +02:00
|
|
|
golden.RequireEqualTxt(t, w.Bytes())
|
2021-03-01 19:18:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestNoticeCustom(t *testing.T) {
|
|
|
|
var w bytes.Buffer
|
|
|
|
|
|
|
|
color.NoColor = true
|
|
|
|
log.SetHandler(cli.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)
|
|
|
|
|
2021-05-31 02:53:40 +02:00
|
|
|
golden.RequireEqualTxt(t, w.Bytes())
|
2018-02-17 17:43:29 +02:00
|
|
|
}
|