1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipe/defaults/defaults_test.go
Manuel Vogel e92bbe32ce feat: full gitlab support for brew and scoop (#1084)
* makes context tokentype a public var

* passes artifacts object into client upload function. extracts gitlab upload hash from url

* adds gitlab url to brew config

* build brew formula depending on token type

* fixes client for release tests

* fixes exiting brew tests

* fixes scoop test with dummy client adaption

* uses new artifact upload hash

* fixes brew usage

* updates gitlab createFile for brew

* fixes logging for non-existing file in gitlab logging

* fix: gitlab createFile

* fix: removes encoding from gitlab create and update file opts

* fix: gitlab upload and artifact set upload hash

* fix: linter

* changed artifact item to a pointer in ctx

* docs: updates homebrew

* feat: enables scoop for gitlab release

* fix: scoop panic for pointer access

* chore: rename formula build func for brew

* chore: brew removes comments

* fix: brew tests

* test: updates brew tests

* docs: updates homebrew

* test: for token type not implemented for brew

* tests: for multiple linux builds

* fix: build artifacts are pointer in scoop

* test: for scoop and gitlab

* test: for artifacts set upload hash

* adds missing files after adaption

* chore: removes and clarifies comments

* fix: moves artifact upload hash to extra map

* adds comment why we initialize the extra map
2019-08-13 15:28:03 -03:00

103 lines
2.9 KiB
Go

package defaults
import (
"testing"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/assert"
)
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.String())
}
func TestFillBasicData(t *testing.T) {
_, back := testlib.Mktmp(t)
defer back()
testlib.GitInit(t)
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
var ctx = &context.Context{
TokenType: context.TokenTypeGitHub,
Config: config.Project{},
}
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.Archives[0].Format)
assert.Contains(t, ctx.Config.Brews[0].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.Archives[0].NameTemplate)
assert.NotEmpty(t, ctx.Config.Builds[0].Ldflags)
assert.NotEmpty(t, ctx.Config.Archives[0].Files)
assert.NotEmpty(t, ctx.Config.Dist)
}
func TestFillPartial(t *testing.T) {
_, back := testlib.Mktmp(t)
defer back()
testlib.GitInit(t)
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
var ctx = &context.Context{
Config: config.Project{
GitHubURLs: config.GitHubURLs{
Download: "https://github.company.com",
},
Dist: "disttt",
Release: config.Release{
GitHub: config.Repo{
Owner: "goreleaser",
Name: "test",
},
},
Archive: config.Archive{
Files: []string{
"glob/*",
},
},
Builds: []config.Build{
{
ID: "build1",
Binary: "testreleaser",
},
{Goos: []string{"linux"}},
{
ID: "build3",
Binary: "another",
Ignore: []config.IgnoredBuild{
{Goos: "darwin", Goarch: "amd64"},
},
},
},
Dockers: []config.Docker{
{
ImageTemplates: []string{"a/b"},
},
},
},
}
assert.NoError(t, Pipe{}.Run(ctx))
assert.Len(t, ctx.Config.Archive.Files, 1)
assert.Equal(t, `bin.install "testreleaser"`, ctx.Config.Brews[0].Install)
assert.NotEmpty(t, ctx.Config.Dockers[0].Binaries)
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)
}