mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-09 13:36:56 +02:00
alternative to #3806 the idea is that both `context.New` and `context.Context{}` are never used in tests. not sure yet how much I like it, so far code does look a bit more readable though. --------- Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
48 lines
957 B
Go
48 lines
957 B
Go
package custompublishers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/testctx"
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDescription(t *testing.T) {
|
|
require.NotEmpty(t, Pipe{}.String())
|
|
}
|
|
|
|
func TestSkip(t *testing.T) {
|
|
t.Run("skip", func(t *testing.T) {
|
|
require.True(t, Pipe{}.Skip(testctx.New()))
|
|
})
|
|
|
|
t.Run("skip on skip-publish", func(t *testing.T) {
|
|
ctx := testctx.NewWithCfg(config.Project{
|
|
Publishers: []config.Publisher{
|
|
{},
|
|
},
|
|
}, testctx.SkipPublish)
|
|
require.True(t, Pipe{}.Skip(ctx))
|
|
})
|
|
|
|
t.Run("dont skip", func(t *testing.T) {
|
|
ctx := testctx.NewWithCfg(config.Project{
|
|
Publishers: []config.Publisher{
|
|
{},
|
|
},
|
|
})
|
|
require.False(t, Pipe{}.Skip(ctx))
|
|
})
|
|
}
|
|
|
|
func TestPublish(t *testing.T) {
|
|
require.NoError(t, Pipe{}.Publish(testctx.NewWithCfg(config.Project{
|
|
Publishers: []config.Publisher{
|
|
{
|
|
Cmd: "echo",
|
|
},
|
|
},
|
|
})))
|
|
}
|