1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/defaults/defaults_test.go

80 lines
1.8 KiB
Go
Raw Normal View History

2017-01-14 18:29:01 +02:00
package defaults
import (
2017-04-22 15:21:23 +02:00
"io/ioutil"
"os"
2017-01-14 18:29:01 +02:00
"testing"
2017-01-15 00:01:32 +02:00
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
2017-01-14 18:29:01 +02:00
"github.com/stretchr/testify/assert"
)
2017-03-26 01:43:42 +02:00
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.Description())
}
2017-01-14 18:29:01 +02:00
func TestFillBasicData(t *testing.T) {
assert := assert.New(t)
var ctx = &context.Context{
2017-01-18 19:08:48 +02:00
Config: config.Project{},
2017-01-14 18:29:01 +02:00
}
assert.NoError(Pipe{}.Run(ctx))
2017-03-23 02:01:29 +02:00
assert.Equal("goreleaser", ctx.Config.Release.GitHub.Owner)
assert.Equal("goreleaser", ctx.Config.Release.GitHub.Name)
2017-03-23 02:06:37 +02:00
assert.Equal("goreleaser", ctx.Config.Build.Binary)
assert.Equal(".", ctx.Config.Build.Main)
2017-01-18 19: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 18:38:48 +02:00
assert.NotEmpty(
2017-01-18 19:08:48 +02:00
ctx.Config.Archive.NameTemplate,
ctx.Config.Build.Ldflags,
ctx.Config.Archive.Files,
2017-01-14 18:38:48 +02:00
)
}
2017-05-01 14:59:18 +02: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 19:08:48 +02:00
Archive: config.Archive{
Files: []string{
2017-05-11 05:05:51 +02:00
"glob/*",
2017-01-18 19:08:48 +02:00
},
2017-01-14 23:52:39 +02:00
},
2017-01-14 18:38:48 +02:00
},
}
assert.NoError(Pipe{}.Run(ctx))
2017-01-18 19:08:48 +02:00
assert.Len(ctx.Config.Archive.Files, 1)
2017-01-14 18:38:48 +02:00
}
2017-04-22 15:21:23 +02: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))
}