Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make scoop write .json when --skip-publish #2380

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions internal/pipe/scoop/scoop.go
Expand Up @@ -34,10 +34,6 @@ func (Pipe) String() string {

// Publish scoop manifest.
func (Pipe) Publish(ctx *context.Context) error {
if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled
}

client, err := client.New(ctx)
if err != nil {
return err
Expand Down
31 changes: 28 additions & 3 deletions internal/pipe/scoop/scoop_test.go
Expand Up @@ -997,8 +997,7 @@ func Test_buildManifest(t *testing.T) {
}
}

func TestRunPipeScoopWithSkip(t *testing.T) {
folder := t.TempDir()
func getScoopPipeSkipCtx(folder string) (*context.Context, string) {
ctx := &context.Context{
Git: context.GitInfo{
CurrentTag: "v1.0.1",
Expand All @@ -1022,11 +1021,12 @@ func TestRunPipeScoopWithSkip(t *testing.T) {
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
Name: "run-pipe",
SkipUpload: "true",
},
},
}

path := filepath.Join(folder, "bin.tar.gz")

ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin.tar.gz",
Path: path,
Expand All @@ -1039,6 +1039,14 @@ func TestRunPipeScoopWithSkip(t *testing.T) {
},
})

return ctx, path
}

func TestRunPipeScoopWithSkipUpload(t *testing.T) {
folder := t.TempDir()
ctx, path := getScoopPipeSkipCtx(folder)
ctx.Config.Scoop.SkipUpload = "true"

f, err := os.Create(path)
require.NoError(t, err)
require.NoError(t, f.Close())
Expand All @@ -1051,6 +1059,23 @@ func TestRunPipeScoopWithSkip(t *testing.T) {
require.NoError(t, err, "file should exist: "+distFile)
}

func TestRunPipeScoopWithSkipPublish(t *testing.T) {
folder := t.TempDir()
ctx, path := getScoopPipeSkipCtx(folder)
ctx.SkipPublish = true

f, err := os.Create(path)
require.NoError(t, err)
require.NoError(t, f.Close())

cli := &DummyClient{}
require.EqualError(t, doRun(ctx, cli), pipe.ErrSkipPublishEnabled.Error())

distFile := filepath.Join(folder, ctx.Config.Scoop.Name+".json")
_, err = os.Stat(distFile)
require.NoError(t, err, "file should exist: "+distFile)
caarlos0 marked this conversation as resolved.
Show resolved Hide resolved
}

func TestWrapInDirectory(t *testing.T) {
folder := t.TempDir()
file := filepath.Join(folder, "archive")
Expand Down