1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/pipeline/defaults/defaults_test.go

80 lines
1.8 KiB
Go
Raw Normal View History

2017-01-14 14:29:01 -02:00
package defaults
import (
2017-04-22 10:21:23 -03:00
"io/ioutil"
"os"
2017-01-14 14:29:01 -02:00
"testing"
2017-01-14 20:01:32 -02:00
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
2017-01-14 14:29:01 -02:00
"github.com/stretchr/testify/assert"
)
2017-03-25 20:43:42 -03:00
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.Description())
}
2017-01-14 14:29:01 -02:00
func TestFillBasicData(t *testing.T) {
assert := assert.New(t)
var ctx = &context.Context{
2017-01-18 15:08:48 -02:00
Config: config.Project{},
2017-01-14 14:29:01 -02:00
}
assert.NoError(Pipe{}.Run(ctx))
2017-03-22 21:01:29 -03:00
assert.Equal("goreleaser", ctx.Config.Release.GitHub.Owner)
assert.Equal("goreleaser", ctx.Config.Release.GitHub.Name)
2017-03-22 21:06:37 -03:00
assert.Equal("goreleaser", ctx.Config.Build.Binary)
assert.Equal(".", ctx.Config.Build.Main)
2017-01-18 15:08:48 -02:00
assert.Equal("tar.gz", ctx.Config.Archive.Format)
assert.Contains(ctx.Config.Build.Goos, "darwin")
assert.Contains(ctx.Config.Build.Goos, "linux")
assert.Contains(ctx.Config.Build.Goarch, "386")
assert.Contains(ctx.Config.Build.Goarch, "amd64")
assert.Contains(ctx.Config.Brew.Install, "bin.install \"goreleaser\"")
2017-01-14 14:38:48 -02:00
assert.NotEmpty(
2017-01-18 15:08:48 -02:00
ctx.Config.Archive.NameTemplate,
ctx.Config.Build.Ldflags,
ctx.Config.Archive.Files,
2017-01-14 14:38:48 -02:00
)
}
2017-05-01 09:59:18 -03:00
func TestFillPartial(t *testing.T) {
assert := assert.New(t)
var ctx = &context.Context{
Config: config.Project{
Release: config.Release{
GitHub: config.Repo{
Owner: "goreleaser",
Name: "test",
},
},
2017-01-18 15:08:48 -02:00
Archive: config.Archive{
Files: []string{
2017-05-11 00:05:51 -03:00
"glob/*",
2017-01-18 15:08:48 -02:00
},
2017-01-14 19:52:39 -02:00
},
2017-01-14 14:38:48 -02:00
},
}
assert.NoError(Pipe{}.Run(ctx))
2017-01-18 15:08:48 -02:00
assert.Len(ctx.Config.Archive.Files, 1)
2017-01-14 14:38:48 -02:00
}
2017-04-22 10:21:23 -03:00
func TestNotAGitRepo(t *testing.T) {
var assert = assert.New(t)
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(err)
previous, err := os.Getwd()
assert.NoError(err)
assert.NoError(os.Chdir(folder))
defer func() {
assert.NoError(os.Chdir(previous))
}()
var ctx = &context.Context{
Config: config.Project{},
}
assert.Error(Pipe{}.Run(ctx))
}