2018-02-10 13:04:49 +00:00
|
|
|
package scoop
|
|
|
|
|
|
|
|
import (
|
2020-07-06 14:48:17 +01:00
|
|
|
ctx "context"
|
2018-02-10 13:04:49 +00:00
|
|
|
"os"
|
2018-09-06 13:20:12 +03:00
|
|
|
"path/filepath"
|
2019-01-05 12:30:26 -02:00
|
|
|
"testing"
|
2018-09-06 13:20:12 +03:00
|
|
|
|
2018-02-10 13:04:49 +00:00
|
|
|
"github.com/goreleaser/goreleaser/internal/artifact"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/client"
|
2021-05-30 21:53:40 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/golden"
|
2018-02-10 13:37:22 +00: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"
|
2018-08-20 22:20:04 -03:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-02-10 13:04:49 +00:00
|
|
|
)
|
|
|
|
|
2018-02-10 13:37:22 +00:00
|
|
|
func TestDescription(t *testing.T) {
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NotEmpty(t, Pipe{}.String())
|
2018-02-10 13:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDefault(t *testing.T) {
|
2020-12-12 13:27:35 -03:00
|
|
|
testlib.Mktmp(t)
|
2018-02-10 13:37:22 +00:00
|
|
|
|
2021-04-25 14:20:49 -03:00
|
|
|
ctx := &context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
2022-04-11 20:19:58 -03:00
|
|
|
Config: config.Project{ProjectName: "barr"},
|
2018-02-10 13:37:22 +00:00
|
|
|
}
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
|
|
require.Equal(t, ctx.Config.ProjectName, ctx.Config.Scoop.Name)
|
|
|
|
require.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Name)
|
|
|
|
require.NotEmpty(t, ctx.Config.Scoop.CommitAuthor.Email)
|
|
|
|
require.NotEmpty(t, ctx.Config.Scoop.CommitMessageTemplate)
|
2018-02-10 13:37:22 +00:00
|
|
|
}
|
|
|
|
|
2018-02-10 13:55:03 +00:00
|
|
|
func Test_doRun(t *testing.T) {
|
2021-04-25 14:20:49 -03:00
|
|
|
folder := testlib.Mktmp(t)
|
|
|
|
file := filepath.Join(folder, "archive")
|
|
|
|
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
|
2018-09-06 13:20:12 +03:00
|
|
|
|
2021-06-26 17:14:42 +00:00
|
|
|
type args struct {
|
|
|
|
ctx *context.Context
|
2021-10-03 13:24:20 -03:00
|
|
|
client *client.Mock
|
2021-06-26 17:14:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type asserter func(*testing.T, args)
|
2018-02-16 10:35:44 -02:00
|
|
|
type errChecker func(*testing.T, error)
|
2021-04-25 14:20:49 -03:00
|
|
|
shouldErr := func(msg string) errChecker {
|
2018-02-16 10:35:44 -02:00
|
|
|
return func(t *testing.T, err error) {
|
2021-01-15 12:54:31 +00:00
|
|
|
t.Helper()
|
2020-10-06 09:48:04 -03:00
|
|
|
require.Error(t, err)
|
|
|
|
require.EqualError(t, err, msg)
|
2018-02-16 10:35:44 -02:00
|
|
|
}
|
|
|
|
}
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions := func(t *testing.T, _ args) {
|
|
|
|
t.Helper()
|
|
|
|
}
|
2021-04-25 14:20:49 -03:00
|
|
|
shouldNotErr := func(t *testing.T, err error) {
|
2021-01-15 12:54:31 +00:00
|
|
|
t.Helper()
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NoError(t, err)
|
2018-02-16 10:35:44 -02:00
|
|
|
}
|
2021-06-26 17:14:42 +00:00
|
|
|
|
2018-02-10 13:55:03 +00:00
|
|
|
tests := []struct {
|
2021-09-18 10:21:29 -03:00
|
|
|
name string
|
|
|
|
args args
|
2021-12-07 18:04:29 -03:00
|
|
|
artifacts []artifact.Artifact
|
2021-09-18 10:21:29 -03:00
|
|
|
assertRunError errChecker
|
|
|
|
assertPublishError errChecker
|
|
|
|
assert asserter
|
2018-02-10 13:55:03 +00:00
|
|
|
}{
|
|
|
|
{
|
2019-08-13 20:28:03 +02:00
|
|
|
"valid public github",
|
2018-02-10 13:55:03 +00:00
|
|
|
args{
|
|
|
|
&context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
2018-02-10 13:55:03 +00:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2018-02-10 13:55:03 +00:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2018-02-10 13:55:03 +00:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
2021-06-26 17:14:42 +00:00
|
|
|
Folder: "scoops",
|
2018-02-10 13:55:03 +00:00
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2022-04-13 21:29:39 -03:00
|
|
|
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file},
|
2018-09-06 13:20:12 +03:00
|
|
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
2018-02-16 10:35:44 -02:00
|
|
|
shouldNotErr,
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2021-06-26 17:14:42 +00:00
|
|
|
func(t *testing.T, a args) {
|
|
|
|
t.Helper()
|
|
|
|
require.Equal(t, "scoops/run-pipe.json", a.client.Path)
|
|
|
|
},
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
2020-04-21 16:11:18 -03:00
|
|
|
{
|
|
|
|
"wrap in directory",
|
|
|
|
args{
|
|
|
|
&context.Context{
|
|
|
|
TokenType: context.TokenTypeGitHub,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2020-04-21 16:11:18 -03:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2020-04-21 16:11:18 -03:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2020-04-21 16:11:18 -03:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2020-04-21 16:11:18 -03:00
|
|
|
{
|
2022-04-11 22:43:22 -03:00
|
|
|
Name: "foo_1.0.1_windows_amd64.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "amd64",
|
2022-04-13 21:29:39 -03:00
|
|
|
Goamd64: "v1",
|
2022-04-11 22:43:22 -03:00
|
|
|
Path: file,
|
2020-04-21 16:11:18 -03:00
|
|
|
Extra: map[string]interface{}{
|
|
|
|
"Wrap": "foo_1.0.1_windows_amd64",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo_1.0.1_windows_386.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "386",
|
|
|
|
Path: file,
|
|
|
|
Extra: map[string]interface{}{
|
|
|
|
"Wrap": "foo_1.0.1_windows_386",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
shouldNotErr,
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2020-04-21 16:11:18 -03:00
|
|
|
},
|
2018-02-11 16:36:59 +00:00
|
|
|
{
|
2019-08-13 20:28:03 +02:00
|
|
|
"valid enterprise github",
|
2018-02-11 16:36:59 +00:00
|
|
|
args{
|
|
|
|
&context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
2018-02-11 16:36:59 +00:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2018-02-11 16:36:59 +00:00
|
|
|
Config: config.Project{
|
2022-04-11 20:19:58 -03:00
|
|
|
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.github.enterprise.com"},
|
2018-02-11 16:36:59 +00:00
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2018-02-11 16:36:59 +00:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2018-02-11 16:36:59 +00:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2022-04-13 21:29:39 -03:00
|
|
|
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file},
|
2018-09-06 13:20:12 +03:00
|
|
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
2018-02-11 16:36:59 +00:00
|
|
|
},
|
2018-02-16 10:35:44 -02:00
|
|
|
shouldNotErr,
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2021-06-26 17:14:42 +00:00
|
|
|
func(t *testing.T, a args) {
|
|
|
|
t.Helper()
|
|
|
|
require.Equal(t, "run-pipe.json", a.client.Path)
|
|
|
|
},
|
2018-02-11 16:36:59 +00:00
|
|
|
},
|
2018-02-10 13:55:03 +00:00
|
|
|
{
|
2019-08-13 20:28:03 +02:00
|
|
|
"valid public gitlab",
|
2018-02-10 13:55:03 +00:00
|
|
|
args{
|
|
|
|
&context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitLab,
|
2018-02-10 13:55:03 +00:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2018-02-10 13:55:03 +00:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2018-02-10 13:55:03 +00:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
2019-08-13 20:28:03 +02:00
|
|
|
Homepage: "https://gitlab.com/goreleaser",
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2019-08-13 20:28:03 +02:00
|
|
|
{
|
2022-04-11 22:43:22 -03:00
|
|
|
Name: "foo_1.0.1_windows_amd64.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "amd64",
|
2022-04-13 21:29:39 -03:00
|
|
|
Goamd64: "v1",
|
2022-04-11 22:43:22 -03:00
|
|
|
Path: file,
|
2019-08-13 20:28:03 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo_1.0.1_windows_386.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "386",
|
|
|
|
Path: file,
|
|
|
|
},
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
2019-08-13 20:28:03 +02:00
|
|
|
shouldNotErr,
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-13 20:28:03 +02:00
|
|
|
"valid enterprise gitlab",
|
2018-02-10 13:55:03 +00:00
|
|
|
args{
|
|
|
|
&context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitLab,
|
2018-02-10 13:55:03 +00:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2018-02-10 13:55:03 +00:00
|
|
|
Config: config.Project{
|
2022-04-11 20:19:58 -03:00
|
|
|
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.gitlab.enterprise.com"},
|
2018-02-10 13:55:03 +00:00
|
|
|
ProjectName: "run-pipe",
|
2019-08-13 20:28:03 +02:00
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2019-08-13 20:28:03 +02:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://gitlab.com/goreleaser",
|
|
|
|
},
|
2018-02-10 13:59:20 +00:00
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2018-02-10 13:59:20 +00:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2019-08-13 20:28:03 +02:00
|
|
|
{
|
2022-04-11 22:43:22 -03:00
|
|
|
Name: "foo_1.0.1_windows_amd64.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "amd64",
|
2022-04-13 21:29:39 -03:00
|
|
|
Goamd64: "v1",
|
2022-04-11 22:43:22 -03:00
|
|
|
Path: file,
|
2019-08-13 20:28:03 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "foo_1.0.1_windows_386.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "386",
|
|
|
|
Path: file,
|
|
|
|
},
|
2018-02-10 13:59:20 +00:00
|
|
|
},
|
2019-08-13 20:28:03 +02:00
|
|
|
shouldNotErr,
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2018-02-10 13:59:20 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-13 20:28:03 +02:00
|
|
|
"no windows build",
|
2018-02-10 13:59:20 +00:00
|
|
|
args{
|
|
|
|
&context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
2018-02-10 13:59:20 +00:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2018-02-10 13:59:20 +00:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2018-02-10 13:59:20 +00:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
2022-04-11 20:19:58 -03:00
|
|
|
[]artifact.Artifact{},
|
|
|
|
shouldErr(ErrNoWindows.Error()),
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2018-02-10 13:55:03 +00:00
|
|
|
},
|
2019-06-29 16:02:40 +02:00
|
|
|
{
|
2019-08-13 20:28:03 +02:00
|
|
|
"is draft",
|
2019-06-29 16:02:40 +02:00
|
|
|
args{
|
|
|
|
&context.Context{
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
2019-06-29 16:02:40 +02:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2019-06-29 16:02:40 +02:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Release: config.Release{
|
2019-08-13 20:28:03 +02:00
|
|
|
Draft: true,
|
|
|
|
},
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2019-06-29 16:02:40 +02:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
2019-08-13 20:28:03 +02:00
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2019-08-13 20:28:03 +02:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2022-04-13 21:29:39 -03:00
|
|
|
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file},
|
2019-08-13 20:28:03 +02:00
|
|
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
|
|
|
},
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2019-08-13 20:28:03 +02:00
|
|
|
shouldErr("release is marked as draft"),
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2019-08-13 20:28:03 +02:00
|
|
|
},
|
2020-02-05 19:05:43 -06:00
|
|
|
{
|
|
|
|
"is prerelease and skip upload set to auto",
|
|
|
|
args{
|
|
|
|
&context.Context{
|
|
|
|
TokenType: context.TokenTypeGitHub,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1-pre.1",
|
|
|
|
},
|
|
|
|
Semver: context.Semver{
|
|
|
|
Major: 1,
|
|
|
|
Minor: 0,
|
|
|
|
Patch: 1,
|
|
|
|
Prerelease: "-pre.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1-pre.1",
|
2020-02-05 19:05:43 -06:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
|
|
|
SkipUpload: "auto",
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2020-02-05 19:05:43 -06:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2020-02-05 19:05:43 -06:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2022-04-13 21:29:39 -03:00
|
|
|
{Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file},
|
2020-02-05 19:05:43 -06:00
|
|
|
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
|
|
|
},
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2020-02-05 19:05:43 -06:00
|
|
|
shouldErr("release is prerelease"),
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2020-02-05 19:05:43 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"skip upload set to true",
|
|
|
|
args{
|
|
|
|
&context.Context{
|
|
|
|
TokenType: context.TokenTypeGitHub,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2020-02-05 19:05:43 -06:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
|
|
|
SkipUpload: "true",
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2020-02-05 19:05:43 -06:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2020-02-05 19:05:43 -06:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2022-04-13 21:29:39 -03:00
|
|
|
{Name: "foo_1.0.1-pre.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file},
|
2020-02-05 19:05:43 -06:00
|
|
|
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
|
|
|
},
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2020-02-05 19:05:43 -06:00
|
|
|
shouldErr("scoop.skip_upload is true"),
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2020-02-05 19:05:43 -06:00
|
|
|
},
|
2019-08-29 01:34:09 +02:00
|
|
|
{
|
|
|
|
"release is disabled",
|
|
|
|
args{
|
|
|
|
&context.Context{
|
|
|
|
TokenType: context.TokenTypeGitHub,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2019-08-29 01:34:09 +02:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Release: config.Release{
|
|
|
|
Disable: true,
|
|
|
|
},
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2019-08-29 01:34:09 +02:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2019-08-29 01:34:09 +02:00
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
[]artifact.Artifact{
|
2022-04-13 21:29:39 -03:00
|
|
|
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Goamd64: "v1", Path: file},
|
2019-08-29 01:34:09 +02:00
|
|
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
|
|
|
},
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2019-08-29 01:34:09 +02:00
|
|
|
shouldErr("release is disabled"),
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2019-08-29 01:34:09 +02:00
|
|
|
},
|
2019-08-13 20:28:03 +02:00
|
|
|
{
|
|
|
|
"no archive",
|
|
|
|
args{
|
|
|
|
&context.Context{
|
|
|
|
TokenType: context.TokenTypeGitHub,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
2021-12-07 18:04:29 -03:00
|
|
|
Version: "1.0.1",
|
2019-08-13 20:28:03 +02:00
|
|
|
Config: config.Project{
|
|
|
|
ProjectName: "run-pipe",
|
2019-06-29 16:02:40 +02:00
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2019-06-29 16:02:40 +02:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 13:24:20 -03:00
|
|
|
client.NewMock(),
|
2019-06-29 16:02:40 +02:00
|
|
|
},
|
2022-04-11 20:19:58 -03:00
|
|
|
[]artifact.Artifact{},
|
|
|
|
shouldErr(ErrNoWindows.Error()),
|
2021-09-18 10:21:29 -03:00
|
|
|
shouldNotErr,
|
2021-06-26 17:14:42 +00:00
|
|
|
noAssertions,
|
2019-06-29 16:02:40 +02:00
|
|
|
},
|
2018-02-10 13:55:03 +00:00
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2021-04-25 14:20:49 -03:00
|
|
|
ctx := tt.args.ctx
|
2021-12-07 18:04:29 -03:00
|
|
|
ctx.Artifacts = artifact.New()
|
2018-02-10 13:55:03 +00:00
|
|
|
for _, a := range tt.artifacts {
|
2021-12-07 21:52:35 -03:00
|
|
|
a.Type = artifact.UploadableArchive
|
2021-12-07 18:04:29 -03:00
|
|
|
ctx.Artifacts.Add(&a)
|
2018-02-10 13:55:03 +00:00
|
|
|
}
|
2018-08-20 22:20:04 -03:00
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
2020-04-29 13:45:18 -07:00
|
|
|
|
2021-09-18 10:21:29 -03:00
|
|
|
tt.assertRunError(t, doRun(ctx, tt.args.client))
|
|
|
|
tt.assertPublishError(t, doPublish(ctx, tt.args.client))
|
2021-06-26 17:14:42 +00:00
|
|
|
tt.assert(t, tt.args)
|
2018-02-10 13:55:03 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-10 13:04:49 +00:00
|
|
|
func Test_buildManifest(t *testing.T) {
|
2021-04-25 14:20:49 -03:00
|
|
|
folder := t.TempDir()
|
|
|
|
file := filepath.Join(folder, "archive")
|
|
|
|
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
|
2018-09-06 13:20:12 +03:00
|
|
|
|
2018-02-10 13:04:49 +00:00
|
|
|
tests := []struct {
|
2021-05-30 21:53:40 -03:00
|
|
|
desc string
|
|
|
|
ctx *context.Context
|
2018-02-10 13:04:49 +00:00
|
|
|
}{
|
|
|
|
{
|
2021-05-30 21:53:40 -03:00
|
|
|
"common",
|
2018-08-21 04:06:55 +03:00
|
|
|
&context.Context{
|
2020-07-06 14:48:17 +01:00
|
|
|
Context: ctx.Background(),
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
2018-08-21 04:06:55 +03:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
|
|
|
Version: "1.0.1",
|
|
|
|
Artifacts: artifact.New(),
|
|
|
|
Config: config.Project{
|
|
|
|
GitHubURLs: config.GitHubURLs{
|
|
|
|
Download: "https://github.com",
|
2018-03-05 20:55:02 -03:00
|
|
|
},
|
2018-08-21 04:06:55 +03:00
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Release: config.Release{
|
|
|
|
GitHub: config.Repo{
|
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
2018-03-05 20:55:02 -03:00
|
|
|
},
|
|
|
|
},
|
2018-08-21 04:06:55 +03:00
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2018-08-21 04:06:55 +03:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
2018-08-25 23:24:42 +03:00
|
|
|
Persist: []string{"data", "config", "test.ini"},
|
2018-08-21 04:06:55 +03:00
|
|
|
},
|
2018-03-05 20:55:02 -03:00
|
|
|
},
|
|
|
|
},
|
2018-02-10 13:04:49 +00:00
|
|
|
},
|
2020-12-05 07:16:32 -08:00
|
|
|
{
|
2021-05-30 21:53:40 -03:00
|
|
|
"pre-post-install",
|
2020-12-05 07:16:32 -08:00
|
|
|
&context.Context{
|
|
|
|
Context: ctx.Background(),
|
|
|
|
TokenType: context.TokenTypeGitHub,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
|
|
|
Version: "1.0.1",
|
|
|
|
Artifacts: artifact.New(),
|
|
|
|
Config: config.Project{
|
|
|
|
GitHubURLs: config.GitHubURLs{
|
|
|
|
Download: "https://github.com",
|
|
|
|
},
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Release: config.Release{
|
|
|
|
GitHub: config.Repo{
|
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Scoop: config.Scoop{
|
|
|
|
Bucket: config.RepoRef{
|
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
Persist: []string{"data", "config", "test.ini"},
|
|
|
|
PreInstall: []string{"Write-Host 'Running preinstall command'"},
|
|
|
|
PostInstall: []string{"Write-Host 'Running postinstall command'"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-02-10 13:04:49 +00:00
|
|
|
{
|
2021-05-30 21:53:40 -03:00
|
|
|
"url template",
|
2018-08-21 04:06:55 +03:00
|
|
|
&context.Context{
|
2020-07-06 14:48:17 +01:00
|
|
|
Context: ctx.Background(),
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitHub,
|
2018-08-21 04:06:55 +03:00
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
|
|
|
Version: "1.0.1",
|
|
|
|
Artifacts: artifact.New(),
|
|
|
|
Config: config.Project{
|
|
|
|
GitHubURLs: config.GitHubURLs{
|
|
|
|
Download: "https://github.com",
|
2018-03-05 20:55:02 -03:00
|
|
|
},
|
2018-08-21 04:06:55 +03:00
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2018-08-21 04:06:55 +03:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
2020-04-29 13:45:18 -07:00
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
|
|
|
URLTemplate: "http://github.mycompany.com/foo/bar/{{ .Tag }}/{{ .ArtifactName }}",
|
|
|
|
CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}",
|
|
|
|
Persist: []string{"data.cfg", "etc"},
|
2018-08-21 04:06:55 +03:00
|
|
|
},
|
2018-03-05 20:55:02 -03:00
|
|
|
},
|
|
|
|
},
|
2018-02-10 13:04:49 +00:00
|
|
|
},
|
2019-08-13 20:28:03 +02:00
|
|
|
{
|
2021-05-30 21:53:40 -03:00
|
|
|
"gitlab url template",
|
2019-08-13 20:28:03 +02:00
|
|
|
&context.Context{
|
2020-07-06 14:48:17 +01:00
|
|
|
Context: ctx.Background(),
|
2019-08-13 20:28:03 +02:00
|
|
|
TokenType: context.TokenTypeGitLab,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
|
|
|
Version: "1.0.1",
|
|
|
|
Artifacts: artifact.New(),
|
|
|
|
Config: config.Project{
|
|
|
|
GitLabURLs: config.GitLabURLs{
|
|
|
|
Download: "https://gitlab.com",
|
|
|
|
},
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2019-08-13 20:28:03 +02:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
2020-04-29 13:45:18 -07:00
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://gitlab.com/goreleaser",
|
2021-05-17 18:33:04 +01:00
|
|
|
URLTemplate: "http://gitlab.mycompany.com/foo/bar/-/releases/{{ .Tag }}/downloads/{{ .ArtifactName }}",
|
2020-04-29 13:45:18 -07:00
|
|
|
CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}",
|
|
|
|
Persist: []string{"data.cfg", "etc"},
|
2019-08-13 20:28:03 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-02-10 13:04:49 +00:00
|
|
|
}
|
2018-08-21 04:06:55 +03:00
|
|
|
|
2018-02-10 13:04:49 +00:00
|
|
|
for _, tt := range tests {
|
2021-05-30 21:53:40 -03:00
|
|
|
t.Run(tt.desc, func(t *testing.T) {
|
2021-04-25 14:20:49 -03:00
|
|
|
ctx := tt.ctx
|
2019-03-31 20:10:26 +03:00
|
|
|
err := Pipe{}.Default(ctx)
|
|
|
|
require.NoError(t, err)
|
2020-07-06 14:48:17 +01:00
|
|
|
|
|
|
|
cl, err := client.New(ctx)
|
|
|
|
require.NoError(t, err)
|
2022-04-11 22:43:22 -03:00
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
2020-07-06 14:48:17 +01:00
|
|
|
|
|
|
|
mf, err := dataFor(ctx, cl, []*artifact.Artifact{
|
2019-01-05 12:30:26 -02:00
|
|
|
{
|
2022-04-11 22:43:22 -03:00
|
|
|
Name: "foo_1.0.1_windows_amd64.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "amd64",
|
2022-04-13 21:29:39 -03:00
|
|
|
Goamd64: "v1",
|
2022-04-11 22:43:22 -03:00
|
|
|
Path: file,
|
2019-01-05 12:30:26 -02:00
|
|
|
Extra: map[string]interface{}{
|
2021-10-16 22:46:11 -03:00
|
|
|
artifact.ExtraBuilds: []*artifact.Artifact{
|
2019-01-05 12:30:26 -02:00
|
|
|
{
|
2020-04-02 23:59:01 +02:00
|
|
|
Name: "foo.exe",
|
2019-01-05 12:30:26 -02:00
|
|
|
},
|
|
|
|
{
|
2020-04-02 23:59:01 +02:00
|
|
|
Name: "bar.exe",
|
2019-01-05 12:30:26 -02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-04-18 20:40:23 +02:00
|
|
|
{
|
|
|
|
Name: "foo_1.0.1_windows_arm.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "arm",
|
|
|
|
Path: file,
|
|
|
|
Extra: map[string]interface{}{
|
2021-10-16 22:46:11 -03:00
|
|
|
artifact.ExtraBuilds: []*artifact.Artifact{
|
2021-04-18 20:40:23 +02:00
|
|
|
{
|
|
|
|
Name: "foo.exe",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar.exe",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-05 12:30:26 -02:00
|
|
|
{
|
|
|
|
Name: "foo_1.0.1_windows_386.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "386",
|
|
|
|
Path: file,
|
|
|
|
Extra: map[string]interface{}{
|
2021-10-16 22:46:11 -03:00
|
|
|
artifact.ExtraBuilds: []*artifact.Artifact{
|
2019-01-05 12:30:26 -02:00
|
|
|
{
|
2020-04-02 23:59:01 +02:00
|
|
|
Name: "foo.exe",
|
2019-01-05 12:30:26 -02:00
|
|
|
},
|
|
|
|
{
|
2020-04-02 23:59:01 +02:00
|
|
|
Name: "bar.exe",
|
2019-01-05 12:30:26 -02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2020-07-06 14:48:17 +01:00
|
|
|
require.NoError(t, err)
|
2018-08-21 04:06:55 +03:00
|
|
|
|
2020-07-06 14:48:17 +01:00
|
|
|
out, err := doBuildManifest(mf)
|
2019-01-05 12:30:26 -02:00
|
|
|
require.NoError(t, err)
|
2018-08-21 04:06:55 +03:00
|
|
|
|
2021-05-30 21:53:40 -03:00
|
|
|
golden.RequireEqualJSON(t, out.Bytes())
|
2019-01-05 12:30:26 -02:00
|
|
|
})
|
2018-02-10 13:04:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-03 04:37:02 +02:00
|
|
|
func getScoopPipeSkipCtx(folder string) (*context.Context, string) {
|
2021-05-24 13:30:31 -04:00
|
|
|
ctx := &context.Context{
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
|
|
|
Version: "1.0.1",
|
|
|
|
Artifacts: artifact.New(),
|
|
|
|
Config: config.Project{
|
2021-05-25 16:49:49 -03:00
|
|
|
Dist: folder,
|
2021-05-24 13:30:31 -04:00
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
|
|
|
Bucket: config.RepoRef{
|
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://github.com/goreleaser",
|
2021-05-25 16:49:49 -03:00
|
|
|
Name: "run-pipe",
|
2021-05-24 13:30:31 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2021-08-03 04:37:02 +02:00
|
|
|
|
2021-05-24 13:30:31 -04:00
|
|
|
path := filepath.Join(folder, "bin.tar.gz")
|
2021-08-03 04:37:02 +02:00
|
|
|
|
2021-05-24 13:30:31 -04:00
|
|
|
ctx.Artifacts.Add(&artifact.Artifact{
|
2022-04-11 22:43:22 -03:00
|
|
|
Name: "bin.tar.gz",
|
|
|
|
Path: path,
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "amd64",
|
2022-04-13 21:29:39 -03:00
|
|
|
Goamd64: "v1",
|
2022-04-11 22:43:22 -03:00
|
|
|
Type: artifact.UploadableArchive,
|
|
|
|
Extra: map[string]interface{}{
|
|
|
|
artifact.ExtraID: "foo",
|
|
|
|
artifact.ExtraFormat: "tar.gz",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
ctx.Artifacts.Add(&artifact.Artifact{
|
|
|
|
Name: "ignored.tar.gz",
|
|
|
|
Path: path,
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "amd64",
|
|
|
|
Goamd64: "v3",
|
|
|
|
Type: artifact.UploadableArchive,
|
2021-05-24 13:30:31 -04:00
|
|
|
Extra: map[string]interface{}{
|
2021-10-16 22:46:11 -03:00
|
|
|
artifact.ExtraID: "foo",
|
|
|
|
artifact.ExtraFormat: "tar.gz",
|
2021-05-24 13:30:31 -04:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2021-08-03 04:37:02 +02:00
|
|
|
return ctx, path
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRunPipeScoopWithSkipUpload(t *testing.T) {
|
|
|
|
folder := t.TempDir()
|
|
|
|
ctx, path := getScoopPipeSkipCtx(folder)
|
|
|
|
ctx.Config.Scoop.SkipUpload = "true"
|
|
|
|
|
2021-05-24 13:30:31 -04:00
|
|
|
f, err := os.Create(path)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, f.Close())
|
|
|
|
|
2021-10-03 13:24:20 -03:00
|
|
|
cli := client.NewMock()
|
2022-04-11 22:43:22 -03:00
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
2021-09-18 10:21:29 -03:00
|
|
|
require.NoError(t, doRun(ctx, cli))
|
|
|
|
require.EqualError(t, doPublish(ctx, cli), `scoop.skip_upload is true`)
|
2021-05-24 13:30:31 -04:00
|
|
|
|
|
|
|
distFile := filepath.Join(folder, ctx.Config.Scoop.Name+".json")
|
|
|
|
_, err = os.Stat(distFile)
|
|
|
|
require.NoError(t, err, "file should exist: "+distFile)
|
|
|
|
}
|
|
|
|
|
2020-04-21 16:11:18 -03:00
|
|
|
func TestWrapInDirectory(t *testing.T) {
|
2021-04-25 14:20:49 -03:00
|
|
|
folder := t.TempDir()
|
|
|
|
file := filepath.Join(folder, "archive")
|
|
|
|
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
|
|
|
|
ctx := &context.Context{
|
2020-04-21 16:11:18 -03:00
|
|
|
TokenType: context.TokenTypeGitLab,
|
|
|
|
Git: context.GitInfo{
|
|
|
|
CurrentTag: "v1.0.1",
|
|
|
|
},
|
|
|
|
Version: "1.0.1",
|
|
|
|
Artifacts: artifact.New(),
|
|
|
|
Config: config.Project{
|
|
|
|
GitLabURLs: config.GitLabURLs{
|
|
|
|
Download: "https://gitlab.com",
|
|
|
|
},
|
|
|
|
ProjectName: "run-pipe",
|
|
|
|
Scoop: config.Scoop{
|
2020-07-06 21:12:41 +01:00
|
|
|
Bucket: config.RepoRef{
|
2020-04-21 16:11:18 -03:00
|
|
|
Owner: "test",
|
|
|
|
Name: "test",
|
|
|
|
},
|
2020-04-29 13:45:18 -07:00
|
|
|
Description: "A run pipe test formula",
|
|
|
|
Homepage: "https://gitlab.com/goreleaser",
|
2021-05-17 18:33:04 +01:00
|
|
|
URLTemplate: "http://gitlab.mycompany.com/foo/bar/-/releases/{{ .Tag }}/downloads/{{ .ArtifactName }}",
|
2020-04-29 13:45:18 -07:00
|
|
|
CommitMessageTemplate: "chore(scoop): update {{ .ProjectName }} version {{ .Tag }}",
|
|
|
|
Persist: []string{"data.cfg", "etc"},
|
2020-04-21 16:11:18 -03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
2020-07-06 14:48:17 +01:00
|
|
|
cl, err := client.New(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
mf, err := dataFor(ctx, cl, []*artifact.Artifact{
|
2020-04-21 16:11:18 -03:00
|
|
|
{
|
2022-04-11 22:43:22 -03:00
|
|
|
Name: "foo_1.0.1_windows_amd64.tar.gz",
|
|
|
|
Goos: "windows",
|
|
|
|
Goarch: "amd64",
|
2022-04-13 21:29:39 -03:00
|
|
|
Goamd64: "v1",
|
2022-04-11 22:43:22 -03:00
|
|
|
Path: file,
|
2020-04-21 16:11:18 -03:00
|
|
|
Extra: map[string]interface{}{
|
2021-10-16 22:46:11 -03:00
|
|
|
artifact.ExtraWrappedIn: "foo_1.0.1_windows_amd64",
|
|
|
|
artifact.ExtraBuilds: []*artifact.Artifact{
|
2020-04-21 16:11:18 -03:00
|
|
|
{
|
|
|
|
Name: "foo.exe",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar.exe",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2020-07-06 14:48:17 +01:00
|
|
|
require.NoError(t, err)
|
2020-04-21 16:11:18 -03:00
|
|
|
|
2020-07-06 14:48:17 +01:00
|
|
|
out, err := doBuildManifest(mf)
|
2020-04-21 16:11:18 -03:00
|
|
|
require.NoError(t, err)
|
2021-05-30 21:53:40 -03:00
|
|
|
golden.RequireEqualJSON(t, out.Bytes())
|
2020-04-21 16:11:18 -03:00
|
|
|
}
|
|
|
|
|
2021-09-18 10:21:29 -03:00
|
|
|
func TestSkip(t *testing.T) {
|
|
|
|
t.Run("skip", func(t *testing.T) {
|
|
|
|
require.True(t, Pipe{}.Skip(context.New(config.Project{})))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("dont skip", func(t *testing.T) {
|
|
|
|
ctx := context.New(config.Project{
|
|
|
|
Scoop: config.Scoop{
|
|
|
|
Bucket: config.RepoRef{
|
|
|
|
Name: "a",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.False(t, Pipe{}.Skip(ctx))
|
|
|
|
})
|
|
|
|
}
|