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

95 lines
2.7 KiB
Go
Raw Normal View History

2017-01-14 18:29:01 +02:00
package defaults
import (
"testing"
2017-01-15 00:01:32 +02:00
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/testlib"
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{}.String())
2017-03-26 01:43:42 +02:00
}
2017-01-14 18:29:01 +02:00
func TestFillBasicData(t *testing.T) {
_, back := testlib.Mktmp(t)
defer back()
testlib.GitInit(t)
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
2017-01-14 18:29:01 +02:00
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(t, Pipe{}.Run(ctx))
assert.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Owner)
assert.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Name)
assert.NotEmpty(t, ctx.Config.Builds)
assert.Equal(t, "goreleaser", ctx.Config.Builds[0].Binary)
assert.Equal(t, ".", ctx.Config.Builds[0].Main)
assert.Contains(t, ctx.Config.Builds[0].Goos, "darwin")
assert.Contains(t, ctx.Config.Builds[0].Goos, "linux")
assert.Contains(t, ctx.Config.Builds[0].Goarch, "386")
assert.Contains(t, ctx.Config.Builds[0].Goarch, "amd64")
assert.Equal(t, "tar.gz", ctx.Config.Archive.Format)
assert.Contains(t, ctx.Config.Brew.Install, "bin.install \"goreleaser\"")
assert.Empty(t, ctx.Config.Dockers)
assert.Equal(t, "https://github.com", ctx.Config.GitHubURLs.Download)
assert.NotEmpty(t, ctx.Config.Archive.NameTemplate)
assert.NotEmpty(t, ctx.Config.Builds[0].Ldflags)
assert.NotEmpty(t, ctx.Config.Archive.Files)
assert.NotEmpty(t, ctx.Config.Dist)
2017-01-14 18:38:48 +02:00
}
2017-05-01 14:59:18 +02:00
func TestFillPartial(t *testing.T) {
_, back := testlib.Mktmp(t)
defer back()
testlib.GitInit(t)
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
2017-05-01 14:59:18 +02:00
var ctx = &context.Context{
Config: config.Project{
GitHubURLs: config.GitHubURLs{
Download: "https://github.company.com",
},
Dist: "disttt",
2017-05-01 14:59:18 +02:00
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-07-02 02:13:02 +02:00
Builds: []config.Build{
{Binary: "testreleaser"},
2017-07-02 03:06:40 +02:00
{Goos: []string{"linux"}},
{
Binary: "another",
Ignore: []config.IgnoredBuild{
{Goos: "darwin", Goarch: "amd64"},
},
},
2017-07-02 02:13:02 +02:00
},
2017-09-12 05:49:02 +02:00
Dockers: []config.Docker{
{Image: "a/b"},
},
2017-01-14 18:38:48 +02:00
},
}
assert.NoError(t, Pipe{}.Run(ctx))
assert.Len(t, ctx.Config.Archive.Files, 1)
assert.Equal(t, `bin.install "testreleaser"`, ctx.Config.Brew.Install)
assert.NotEmpty(t, ctx.Config.Dockers[0].Binary)
assert.NotEmpty(t, ctx.Config.Dockers[0].Goos)
assert.NotEmpty(t, ctx.Config.Dockers[0].Goarch)
assert.NotEmpty(t, ctx.Config.Dockers[0].Dockerfile)
assert.Empty(t, ctx.Config.Dockers[0].Goarm)
assert.Equal(t, "disttt", ctx.Config.Dist)
assert.NotEqual(t, "https://github.com", ctx.Config.GitHubURLs.Download)
2017-01-14 18:38:48 +02:00
}