1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-04-07 07:10:11 +02:00

fixed tests

This commit is contained in:
Carlos Alexandro Becker 2017-08-20 16:50:34 -03:00
parent 8f67faf2d0
commit ce7a2227a0
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
7 changed files with 43 additions and 16 deletions

14
internal/testlib/skip.go Normal file
View File

@ -0,0 +1,14 @@
package testlib
import (
"testing"
"github.com/goreleaser/goreleaser/pipeline"
"github.com/stretchr/testify/assert"
)
// AssertSkipped asserts that a pipe was skipped
func AssertSkipped(t *testing.T, err error) {
_, ok := err.(pipeline.ErrSkip)
assert.True(t, ok)
}

View File

@ -0,0 +1,11 @@
package testlib
import (
"testing"
"github.com/goreleaser/goreleaser/pipeline"
)
func TestAssertSkipped(t *testing.T) {
AssertSkipped(t, pipeline.Skip("skip"))
}

View File

@ -9,6 +9,7 @@ import (
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/stretchr/testify/assert"
)
@ -202,7 +203,7 @@ func TestRunPipeBrewNotSetup(t *testing.T) {
Publish: true,
}
client := &DummyClient{}
assert.NoError(doRun(ctx, client))
testlib.AssertSkipped(t, doRun(ctx, client))
assert.False(client.CreatedFile)
}
@ -224,7 +225,7 @@ func TestRunPipeBinaryRelease(t *testing.T) {
}
ctx.AddBinary("darwinamd64", "foo", "bar", "baz")
client := &DummyClient{}
assert.NoError(doRun(ctx, client))
testlib.AssertSkipped(t, doRun(ctx, client))
assert.False(client.CreatedFile)
}
@ -234,7 +235,7 @@ func TestRunPipeNoPublish(t *testing.T) {
Publish: false,
}
client := &DummyClient{}
assert.NoError(doRun(ctx, client))
testlib.AssertSkipped(t, doRun(ctx, client))
assert.False(client.CreatedFile)
}
@ -255,7 +256,7 @@ func TestRunPipeDraftRelease(t *testing.T) {
},
}
client := &DummyClient{}
assert.NoError(doRun(ctx, client))
testlib.AssertSkipped(t, doRun(ctx, client))
assert.False(client.CreatedFile)
}
@ -269,7 +270,7 @@ func TestRunPipeFormatBinary(t *testing.T) {
},
}
client := &DummyClient{}
assert.NoError(doRun(ctx, client))
testlib.AssertSkipped(t, doRun(ctx, client))
assert.False(client.CreatedFile)
}

View File

@ -7,6 +7,7 @@ import (
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/stretchr/testify/assert"
)
@ -61,7 +62,7 @@ func TestInvalidEnvChecksSkipped(t *testing.T) {
Publish: flag.Publish,
Snapshot: flag.Snapshot,
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
})
}
}

View File

@ -8,6 +8,7 @@ import (
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/stretchr/testify/assert"
)
@ -16,12 +17,11 @@ func TestDescription(t *testing.T) {
}
func TestRunPipeNoFormats(t *testing.T) {
var assert = assert.New(t)
var ctx = &context.Context{
Version: "1.0.0",
Config: config.Project{},
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
}
func TestRunPipe(t *testing.T) {

View File

@ -37,7 +37,7 @@ func TestSingleCommit(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{},
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
assert.Equal("v0.0.1", ctx.Git.CurrentTag)
}
@ -67,7 +67,7 @@ func TestNoTagsSnapshot(t *testing.T) {
Snapshot: true,
Publish: false,
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
assert.Contains(ctx.Version, "SNAPSHOT-")
}
@ -182,7 +182,6 @@ func TestValidState(t *testing.T) {
}
func TestNoValidate(t *testing.T) {
var assert = assert.New(t)
_, back := testlib.Mktmp(t)
defer back()
testlib.GitInit(t)
@ -194,7 +193,7 @@ func TestNoValidate(t *testing.T) {
Config: config.Project{},
Validate: false,
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
}
func TestChangelog(t *testing.T) {
@ -210,7 +209,7 @@ func TestChangelog(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{},
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
assert.Equal("v0.0.2", ctx.Git.CurrentTag)
assert.Contains(ctx.ReleaseNotes, "## Changelog")
assert.NotContains(ctx.ReleaseNotes, "first")
@ -236,7 +235,7 @@ func TestChangelogOfFirstRelease(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{},
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
assert.Equal("v0.0.1", ctx.Git.CurrentTag)
assert.Contains(ctx.ReleaseNotes, "## Changelog")
for _, msg := range msgs {
@ -255,7 +254,7 @@ func TestCustomReleaseNotes(t *testing.T) {
Config: config.Project{},
ReleaseNotes: "custom",
}
assert.NoError(Pipe{}.Run(ctx))
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
assert.Equal("v0.0.1", ctx.Git.CurrentTag)
assert.Equal(ctx.ReleaseNotes, "custom")
}

View File

@ -10,6 +10,7 @@ import (
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/stretchr/testify/assert"
)
@ -121,7 +122,7 @@ func TestSkipPublish(t *testing.T) {
Parallelism: 1,
}
client := &DummyClient{}
assert.NoError(doRun(ctx, client))
testlib.AssertSkipped(t, doRun(ctx, client))
assert.False(client.CreatedRelease)
assert.False(client.UploadedFile)
}