2017-01-14 14:29:01 -02:00
|
|
|
package defaults
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-10-15 17:46:21 -02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/testlib"
|
2018-08-14 23:50:20 -03:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2020-10-06 09:48:04 -03:00
|
|
|
"github.com/stretchr/testify/require"
|
2017-01-14 14:29:01 -02:00
|
|
|
)
|
|
|
|
|
2017-03-25 20:43:42 -03:00
|
|
|
func TestDescription(t *testing.T) {
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NotEmpty(t, Pipe{}.String())
|
2017-03-25 20:43:42 -03:00
|
|
|
}
|
|
|
|
|
2017-01-14 14:29:01 -02:00
|
|
|
func TestFillBasicData(t *testing.T) {
|
2017-10-15 17:46:21 -02:00
|
|
|
_, back := testlib.Mktmp(t)
|
|
|
|
defer back()
|
|
|
|
testlib.GitInit(t)
|
|
|
|
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
|
|
|
|
2017-01-14 14:29:01 -02:00
|
|
|
var ctx = &context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
|
|
|
Config: config.Project{},
|
2017-01-14 14:29:01 -02:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NoError(t, Pipe{}.Run(ctx))
|
|
|
|
require.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Owner)
|
|
|
|
require.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Name)
|
|
|
|
require.NotEmpty(t, ctx.Config.Builds)
|
|
|
|
require.Equal(t, "goreleaser", ctx.Config.Builds[0].Binary)
|
|
|
|
require.Equal(t, ".", ctx.Config.Builds[0].Main)
|
|
|
|
require.Contains(t, ctx.Config.Builds[0].Goos, "darwin")
|
|
|
|
require.Contains(t, ctx.Config.Builds[0].Goos, "linux")
|
|
|
|
require.Contains(t, ctx.Config.Builds[0].Goarch, "386")
|
|
|
|
require.Contains(t, ctx.Config.Builds[0].Goarch, "amd64")
|
|
|
|
require.Equal(t, "tar.gz", ctx.Config.Archives[0].Format)
|
|
|
|
require.Empty(t, ctx.Config.Dockers)
|
|
|
|
require.Equal(t, "https://github.com", ctx.Config.GitHubURLs.Download)
|
|
|
|
require.NotEmpty(t, ctx.Config.Archives[0].NameTemplate)
|
|
|
|
require.NotEmpty(t, ctx.Config.Builds[0].Ldflags)
|
|
|
|
require.NotEmpty(t, ctx.Config.Archives[0].Files)
|
|
|
|
require.NotEmpty(t, ctx.Config.Dist)
|
2017-01-14 14:38:48 -02:00
|
|
|
}
|
|
|
|
|
2017-05-01 09:59:18 -03:00
|
|
|
func TestFillPartial(t *testing.T) {
|
2017-10-15 17:46:21 -02:00
|
|
|
_, back := testlib.Mktmp(t)
|
|
|
|
defer back()
|
|
|
|
testlib.GitInit(t)
|
|
|
|
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
2017-05-01 09:59:18 -03:00
|
|
|
|
|
|
|
var ctx = &context.Context{
|
|
|
|
Config: config.Project{
|
2018-02-15 00:08:28 -02:00
|
|
|
GitHubURLs: config.GitHubURLs{
|
|
|
|
Download: "https://github.company.com",
|
|
|
|
},
|
2017-11-26 21:25:51 -02:00
|
|
|
Dist: "disttt",
|
2017-05-01 09:59:18 -03:00
|
|
|
Release: config.Release{
|
|
|
|
GitHub: config.Repo{
|
|
|
|
Owner: "goreleaser",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
},
|
2019-12-29 15:02:15 -03:00
|
|
|
Archives: []config.Archive{
|
|
|
|
{
|
|
|
|
Files: []string{
|
|
|
|
"glob/*",
|
|
|
|
},
|
2017-01-18 15:08:48 -02:00
|
|
|
},
|
2017-01-14 19:52:39 -02:00
|
|
|
},
|
2017-07-01 21:13:02 -03:00
|
|
|
Builds: []config.Build{
|
2019-06-28 08:52:10 -03:00
|
|
|
{
|
|
|
|
ID: "build1",
|
|
|
|
Binary: "testreleaser",
|
|
|
|
},
|
2017-07-01 22:06:40 -03:00
|
|
|
{Goos: []string{"linux"}},
|
|
|
|
{
|
2019-06-28 08:52:10 -03:00
|
|
|
ID: "build3",
|
2017-07-01 22:06:40 -03:00
|
|
|
Binary: "another",
|
|
|
|
Ignore: []config.IgnoredBuild{
|
|
|
|
{Goos: "darwin", Goarch: "amd64"},
|
|
|
|
},
|
|
|
|
},
|
2017-07-01 21:13:02 -03:00
|
|
|
},
|
2017-09-12 00:49:02 -03:00
|
|
|
Dockers: []config.Docker{
|
2019-01-11 16:27:39 -02:00
|
|
|
{
|
|
|
|
ImageTemplates: []string{"a/b"},
|
|
|
|
},
|
2017-09-12 00:49:02 -03:00
|
|
|
},
|
2020-01-26 18:36:01 -03:00
|
|
|
Brews: []config.Homebrew{
|
|
|
|
{
|
|
|
|
Description: "foo",
|
|
|
|
},
|
|
|
|
},
|
2017-01-14 14:38:48 -02:00
|
|
|
},
|
|
|
|
}
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NoError(t, Pipe{}.Run(ctx))
|
|
|
|
require.Len(t, ctx.Config.Archives[0].Files, 1)
|
|
|
|
require.Equal(t, `bin.install "testreleaser"`, ctx.Config.Brews[0].Install)
|
|
|
|
require.NotEmpty(t, ctx.Config.Dockers[0].Binaries)
|
|
|
|
require.NotEmpty(t, ctx.Config.Dockers[0].Goos)
|
|
|
|
require.NotEmpty(t, ctx.Config.Dockers[0].Goarch)
|
|
|
|
require.NotEmpty(t, ctx.Config.Dockers[0].Dockerfile)
|
|
|
|
require.Empty(t, ctx.Config.Dockers[0].Goarm)
|
|
|
|
require.Equal(t, "disttt", ctx.Config.Dist)
|
|
|
|
require.NotEqual(t, "https://github.com", ctx.Config.GitHubURLs.Download)
|
2017-01-14 14:38:48 -02:00
|
|
|
}
|