1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-21 21:07:19 +02:00
goreleaser/internal/pipe/dist/dist_test.go

47 lines
1.2 KiB
Go
Raw Normal View History

package dist
2017-07-04 22:53:50 -03:00
import (
"os"
"path/filepath"
"testing"
"github.com/goreleaser/goreleaser/v2/internal/testctx"
"github.com/goreleaser/goreleaser/v2/pkg/config"
"github.com/stretchr/testify/require"
2017-07-04 22:53:50 -03:00
)
func TestDistDoesNotExist(t *testing.T) {
folder := t.TempDir()
dist := filepath.Join(folder, "dist")
require.NoError(t, Pipe{}.Run(testctx.NewWithCfg(config.Project{Dist: dist})))
2017-07-04 22:53:50 -03:00
}
func TestPopulatedDistExists(t *testing.T) {
folder := t.TempDir()
dist := filepath.Join(folder, "dist")
require.NoError(t, os.Mkdir(dist, 0o755))
f, err := os.Create(filepath.Join(dist, "mybin"))
require.NoError(t, err)
require.NoError(t, f.Close())
ctx := testctx.NewWithCfg(config.Project{Dist: dist})
require.Error(t, Pipe{}.Run(ctx))
ctx.Clean = true
require.NoError(t, Pipe{}.Run(ctx))
2017-07-04 22:53:50 -03:00
_, err = os.Stat(dist)
require.False(t, os.IsExist(err))
2017-07-04 22:53:50 -03:00
}
func TestEmptyDistExists(t *testing.T) {
folder := t.TempDir()
dist := filepath.Join(folder, "dist")
require.NoError(t, os.Mkdir(dist, 0o755))
ctx := testctx.NewWithCfg(config.Project{Dist: dist})
require.NoError(t, Pipe{}.Run(ctx))
_, err := os.Stat(dist)
require.False(t, os.IsNotExist(err))
2017-07-04 22:53:50 -03:00
}
func TestDescription(t *testing.T) {
require.NotEmpty(t, Pipe{}.String())
2017-07-04 22:53:50 -03:00
}