mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
06ddedf12a
Writes the actual config file (with defaults merged, etc) into the dist folder. Can be useful for debug purposes.
64 lines
1.3 KiB
Go
64 lines
1.3 KiB
Go
package dist
|
|
|
|
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{}.String())
|
|
}
|