Skip to content
Permalink
Browse files

fix: s3: honor skip upload (#738)

refs #737
  • Loading branch information...
caarlos0 committed Jul 27, 2018
1 parent ba62d25 commit 82493e2928dabcb4abd7d86acfbf6e7ca2543d39
Showing with 34 additions and 0 deletions.
  1. +4 −0 pipeline/s3/s3.go
  2. +30 −0 pipeline/s3/s3_test.go
@@ -15,6 +15,7 @@ import (
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pipeline"
)

// Pipe for Artifactory
@@ -47,6 +48,9 @@ func (Pipe) Default(ctx *context.Context) error {

// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.SkipPublish {
return pipeline.ErrSkipPublishEnabled
}
var g = semerrgroup.New(ctx.Parallelism)
for _, conf := range ctx.Config.S3 {
conf := conf
@@ -13,7 +13,9 @@ import (
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/pipeline"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDescription(t *testing.T) {
@@ -53,6 +55,34 @@ func TestDefaults(t *testing.T) {
}}, ctx.Config.S3)
}

func TestSkipPublish(t *testing.T) {
folder, err := ioutil.TempDir("", "goreleasertest")
require.NoError(t, err)
artifactPath := filepath.Join(folder, "foo.tar.gz")
require.NoError(t, ioutil.WriteFile(artifactPath, []byte("fake\ntargz"), 0744))
var ctx = context.New(config.Project{
Dist: folder,
ProjectName: "testupload",
S3: []config.S3{
{
Bucket: "test",
Endpoint: "http://fake.s3.example",
},
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "foo.tar.gz",
Path: artifactPath,
})
ctx.SkipPublish = true
require.NoError(t, Pipe{}.Default(ctx))
err = Pipe{}.Run(ctx)
assert.True(t, pipeline.IsSkip(err))
assert.EqualError(t, err, pipeline.ErrSkipPublishEnabled.Error())
}

func TestUpload(t *testing.T) {
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(t, err)

0 comments on commit 82493e2

Please sign in to comment.
You can’t perform that action at this time.