1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
Carlos Alexandro Becker d85a9001ec
removing all assert.New because vet shadow complains about this now
aaaaaaaaaaarhhhhhhhhgttt
2017-09-26 19:24:49 -03:00

64 lines
1.3 KiB
Go

package cleandist
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/stretchr/testify/assert"
)
func TestDistDoesNotExist(t *testing.T) {
assert.NoError(
t,
Pipe{}.Run(
&context.Context{
Config: config.Project{
Dist: "/wtf-this-shouldnt-exist",
},
},
),
)
}
func TestPopulatedDistExists(t *testing.T) {
folder, err := ioutil.TempDir("", "disttest")
assert.NoError(t, err)
var dist = filepath.Join(folder, "dist")
assert.NoError(t, os.Mkdir(dist, 0755))
_, err = os.Create(filepath.Join(dist, "mybin"))
assert.NoError(t, err)
var ctx = &context.Context{
Config: config.Project{
Dist: dist,
},
}
assert.Error(t, Pipe{}.Run(ctx))
ctx.RmDist = true
assert.NoError(t, Pipe{}.Run(ctx))
_, err = os.Stat(dist)
assert.False(t, os.IsExist(err))
}
func TestEmptyDistExists(t *testing.T) {
folder, err := ioutil.TempDir("", "disttest")
assert.NoError(t, err)
var dist = filepath.Join(folder, "dist")
assert.NoError(t, os.Mkdir(dist, 0755))
var ctx = &context.Context{
Config: config.Project{
Dist: dist,
},
}
assert.NoError(t, Pipe{}.Run(ctx))
_, err = os.Stat(dist)
assert.False(t, os.IsExist(err))
}
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.Description())
}