1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-11 13:38:41 +02:00

refactor: fix tests

This commit is contained in:
Carlos Alexandro Becker 2018-10-16 21:51:16 -03:00 committed by Carlos Alexandro Becker
parent 089731afc4
commit ad11351902
4 changed files with 0 additions and 45 deletions

View File

@ -25,7 +25,6 @@ func (Pipe) Default(ctx *context.Context) error {
// Publish artifacts
func (Pipe) Publish(ctx *context.Context) error {
if len(ctx.Config.Puts) == 0 {
return pipe.Skip("put section is not configured")
}

View File

@ -50,9 +50,6 @@ func doPublish(ctx *context.Context, c client.Client) error {
if ctx.Config.Release.Disable {
return pipe.Skip("release pipe is disabled")
}
if ctx.SkipPublish {
return pipe.ErrSkipPublishEnabled
}
log.WithField("tag", ctx.Git.CurrentTag).
WithField("repo", ctx.Config.Release.GitHub.String()).
Info("creating or updating release")

View File

@ -125,17 +125,6 @@ func TestRunPipeUploadFailure(t *testing.T) {
assert.False(t, client.UploadedFile)
}
func TestSnapshot(t *testing.T) {
var ctx = &context.Context{
SkipPublish: true,
Parallelism: 1,
}
client := &DummyClient{}
testlib.AssertSkipped(t, doPublish(ctx, client))
assert.False(t, client.CreatedRelease)
assert.False(t, client.UploadedFile)
}
func TestPipeDisabled(t *testing.T) {
var ctx = context.New(config.Project{
Release: config.Release{

View File

@ -11,12 +11,10 @@ import (
"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDescription(t *testing.T) {
@ -56,34 +54,6 @@ 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{}.Publish(ctx)
assert.True(t, pipe.IsSkip(err))
assert.EqualError(t, err, pipe.ErrSkipPublishEnabled.Error())
}
func TestUpload(t *testing.T) {
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(t, err)