mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-07 07:10:11 +02:00
fixed tests
This commit is contained in:
parent
8f67faf2d0
commit
ce7a2227a0
14
internal/testlib/skip.go
Normal file
14
internal/testlib/skip.go
Normal 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)
|
||||
}
|
11
internal/testlib/skip_test.go
Normal file
11
internal/testlib/skip_test.go
Normal file
@ -0,0 +1,11 @@
|
||||
package testlib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/pipeline"
|
||||
)
|
||||
|
||||
func TestAssertSkipped(t *testing.T) {
|
||||
AssertSkipped(t, pipeline.Skip("skip"))
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
||||
|
3
pipeline/env/env_test.go
vendored
3
pipeline/env/env_test.go
vendored
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user