1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/internal/deprecate/deprecate_test.go
Carlos Alexandro Becker a5f0343368
feat: improve check command (#1435)
* feat: improve check command

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: main test

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: tests, finally

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: lint

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-04-12 14:31:35 -03:00

46 lines
976 B
Go

package deprecate
import (
"flag"
"io/ioutil"
"testing"
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
"github.com/fatih/color"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/require"
)
var update = flag.Bool("update", false, "update .golden files")
func TestNotice(t *testing.T) {
f, err := ioutil.TempFile("", "output.txt")
require.NoError(t, err)
color.NoColor = true
log.SetHandler(cli.New(f))
log.Info("first")
var ctx = context.New(config.Project{})
Notice(ctx, "foo.bar.whatever")
log.Info("last")
require.True(t, ctx.Deprecated)
require.NoError(t, f.Close())
bts, err := ioutil.ReadFile(f.Name())
require.NoError(t, err)
const golden = "testdata/output.txt.golden"
if *update {
require.NoError(t, ioutil.WriteFile(golden, bts, 0655))
}
gbts, err := ioutil.ReadFile(golden)
require.NoError(t, err)
require.Equal(t, string(gbts), string(bts))
}