1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipeline/dist/dist_test.go
Carlos Alexandro Becker 64b1f14a86
refactor: better code organization (#757)
* refactor: merging archive in the same repo

* refactor: merging archive in the same repo

* refactor: better organizing packages

* refactor: fixing renames

* fix: new dep version

* fix: makefile

* fix: zip/tar tests

* fix: gitigonore

* fix: s3 tests

* fix: archive test
2018-08-14 23:50:20 -03:00

67 lines
1.4 KiB
Go

package dist
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/assert"
)
func TestDistDoesNotExist(t *testing.T) {
folder, err := ioutil.TempDir("", "disttest")
assert.NoError(t, err)
var dist = filepath.Join(folder, "dist")
assert.NoError(
t,
Pipe{}.Run(
&context.Context{
Config: config.Project{
Dist: dist,
},
},
),
)
}
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.IsNotExist(err))
}
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.String())
}