mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-07 13:31:37 +02:00
refactor: improve scoop tests (#3031)
* refactor: improve scoop tests Signed-off-by: Carlos A Becker <caarlos0@gmail.com> * fix: improve diff a bit
This commit is contained in:
parent
7082217206
commit
acfffe1c98
@ -22,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ErrNoWindows when there is no build for windows (goos doesn't contain windows).
|
// ErrNoWindows when there is no build for windows (goos doesn't contain windows).
|
||||||
var ErrNoWindows = errors.New("scoop requires a windows build")
|
var ErrNoWindows = errors.New("scoop requires a windows build and archive")
|
||||||
|
|
||||||
const scoopConfigExtra = "ScoopConfig"
|
const scoopConfigExtra = "ScoopConfig"
|
||||||
|
|
||||||
@ -65,11 +65,6 @@ func (Pipe) Default(ctx *context.Context) error {
|
|||||||
func doRun(ctx *context.Context, cl client.Client) error {
|
func doRun(ctx *context.Context, cl client.Client) error {
|
||||||
scoop := ctx.Config.Scoop
|
scoop := ctx.Config.Scoop
|
||||||
|
|
||||||
// TODO: multiple archives
|
|
||||||
if ctx.Config.Archives[0].Format == "binary" {
|
|
||||||
return pipe.Skip("archive format is binary")
|
|
||||||
}
|
|
||||||
|
|
||||||
archives := ctx.Artifacts.Filter(
|
archives := ctx.Artifacts.Filter(
|
||||||
artifact.And(
|
artifact.And(
|
||||||
artifact.ByGoos("windows"),
|
artifact.ByGoos("windows"),
|
||||||
|
@ -24,29 +24,7 @@ func TestDefault(t *testing.T) {
|
|||||||
|
|
||||||
ctx := &context.Context{
|
ctx := &context.Context{
|
||||||
TokenType: context.TokenTypeGitHub,
|
TokenType: context.TokenTypeGitHub,
|
||||||
Config: config.Project{
|
Config: config.Project{ProjectName: "barr"},
|
||||||
ProjectName: "barr",
|
|
||||||
Builds: []config.Build{
|
|
||||||
{
|
|
||||||
Binary: "foo",
|
|
||||||
Goos: []string{"linux", "darwin"},
|
|
||||||
Goarch: []string{"386", "amd64"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Binary: "bar",
|
|
||||||
Goos: []string{"linux", "darwin"},
|
|
||||||
Goarch: []string{"386", "amd64"},
|
|
||||||
Ignore: []config.IgnoredBuild{
|
|
||||||
{Goos: "darwin", Goarch: "amd64"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Binary: "foobar",
|
|
||||||
Goos: []string{"linux"},
|
|
||||||
Goarch: []string{"amd64"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
require.NoError(t, Pipe{}.Default(ctx))
|
require.NoError(t, Pipe{}.Default(ctx))
|
||||||
require.Equal(t, ctx.Config.ProjectName, ctx.Config.Scoop.Name)
|
require.Equal(t, ctx.Config.ProjectName, ctx.Config.Scoop.Name)
|
||||||
@ -100,20 +78,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -148,20 +113,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz", WrapInDirectory: "true"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -208,21 +160,8 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.github.enterprise.com"},
|
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.github.enterprise.com"},
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -256,20 +195,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitLab: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -310,21 +236,8 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.gitlab.enterprise.com"},
|
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.gitlab.enterprise.com"},
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -365,20 +278,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test"},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -391,11 +291,8 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
client.NewMock(),
|
client.NewMock(),
|
||||||
},
|
},
|
||||||
[]artifact.Artifact{
|
[]artifact.Artifact{},
|
||||||
{Name: "foo_1.0.1_linux_amd64.tar.gz", Goos: "linux", Goarch: "amd64"},
|
shouldErr(ErrNoWindows.Error()),
|
||||||
{Name: "foo_1.0.1_linux_386.tar.gz", Goos: "linux", Goarch: "386"},
|
|
||||||
},
|
|
||||||
shouldErr("scoop requires a windows build"),
|
|
||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
noAssertions,
|
noAssertions,
|
||||||
},
|
},
|
||||||
@ -409,14 +306,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
Release: config.Release{
|
||||||
Draft: true,
|
Draft: true,
|
||||||
},
|
},
|
||||||
@ -456,20 +346,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1-pre.1",
|
Version: "1.0.1-pre.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
SkipUpload: "auto",
|
SkipUpload: "auto",
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
@ -501,20 +378,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
SkipUpload: "true",
|
SkipUpload: "true",
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
@ -546,14 +410,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
Release: config.Release{
|
||||||
Disable: true,
|
Disable: true,
|
||||||
},
|
},
|
||||||
@ -587,17 +444,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "binary"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
Draft: true,
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -610,11 +457,8 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
client.NewMock(),
|
client.NewMock(),
|
||||||
},
|
},
|
||||||
[]artifact.Artifact{
|
[]artifact.Artifact{},
|
||||||
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
|
shouldErr(ErrNoWindows.Error()),
|
||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
|
||||||
},
|
|
||||||
shouldErr("archive format is binary"),
|
|
||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
noAssertions,
|
noAssertions,
|
||||||
},
|
},
|
||||||
@ -659,11 +503,7 @@ func Test_buildManifest(t *testing.T) {
|
|||||||
GitHubURLs: config.GitHubURLs{
|
GitHubURLs: config.GitHubURLs{
|
||||||
Download: "https://github.com",
|
Download: "https://github.com",
|
||||||
},
|
},
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
Release: config.Release{
|
||||||
GitHub: config.Repo{
|
GitHub: config.Repo{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -696,11 +536,7 @@ func Test_buildManifest(t *testing.T) {
|
|||||||
GitHubURLs: config.GitHubURLs{
|
GitHubURLs: config.GitHubURLs{
|
||||||
Download: "https://github.com",
|
Download: "https://github.com",
|
||||||
},
|
},
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
Release: config.Release{
|
||||||
GitHub: config.Repo{
|
GitHub: config.Repo{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -735,20 +571,7 @@ func Test_buildManifest(t *testing.T) {
|
|||||||
GitHubURLs: config.GitHubURLs{
|
GitHubURLs: config.GitHubURLs{
|
||||||
Download: "https://github.com",
|
Download: "https://github.com",
|
||||||
},
|
},
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test"},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -777,20 +600,7 @@ func Test_buildManifest(t *testing.T) {
|
|||||||
GitLabURLs: config.GitLabURLs{
|
GitLabURLs: config.GitLabURLs{
|
||||||
Download: "https://gitlab.com",
|
Download: "https://gitlab.com",
|
||||||
},
|
},
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test"},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
@ -884,12 +694,6 @@ func getScoopPipeSkipCtx(folder string) (*context.Context, string) {
|
|||||||
Version: "1.0.1",
|
Version: "1.0.1",
|
||||||
Artifacts: artifact.New(),
|
Artifacts: artifact.New(),
|
||||||
Config: config.Project{
|
Config: config.Project{
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz"},
|
|
||||||
},
|
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test"},
|
|
||||||
},
|
|
||||||
Dist: folder,
|
Dist: folder,
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
@ -954,20 +758,7 @@ func TestWrapInDirectory(t *testing.T) {
|
|||||||
GitLabURLs: config.GitLabURLs{
|
GitLabURLs: config.GitLabURLs{
|
||||||
Download: "https://gitlab.com",
|
Download: "https://gitlab.com",
|
||||||
},
|
},
|
||||||
Builds: []config.Build{
|
|
||||||
{Binary: "test"},
|
|
||||||
},
|
|
||||||
Dist: ".",
|
|
||||||
ProjectName: "run-pipe",
|
ProjectName: "run-pipe",
|
||||||
Archives: []config.Archive{
|
|
||||||
{Format: "tar.gz", WrapInDirectory: "true"},
|
|
||||||
},
|
|
||||||
Release: config.Release{
|
|
||||||
GitHub: config.Repo{
|
|
||||||
Owner: "test",
|
|
||||||
Name: "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Scoop: config.Scoop{
|
Scoop: config.Scoop{
|
||||||
Bucket: config.RepoRef{
|
Bucket: config.RepoRef{
|
||||||
Owner: "test",
|
Owner: "test",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user