mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
test: release tests
Added tests for release defaulter
This commit is contained in:
parent
f9cdb2df04
commit
a3a10fab37
@ -109,23 +109,3 @@ func TestFillSingleBuild(t *testing.T) {
|
||||
assert.Equal(t, ctx.Config.Builds[0].Binary, "goreleaser")
|
||||
}
|
||||
|
||||
func TestNotAGitRepo(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.Error(t, Pipe{}.Run(ctx))
|
||||
assert.Empty(t, ctx.Config.Release.GitHub.String())
|
||||
}
|
||||
|
||||
func TestGitRepoWithoutRemote(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.Error(t, Pipe{}.Run(ctx))
|
||||
assert.Empty(t, ctx.Config.Release.GitHub.String())
|
||||
}
|
||||
|
@ -122,6 +122,62 @@ func TestSkipPublish(t *testing.T) {
|
||||
assert.False(t, client.UploadedFile)
|
||||
}
|
||||
|
||||
func TestDefault(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
||||
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.NoError(t, Pipe{}.Default(ctx))
|
||||
assert.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Name)
|
||||
assert.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Owner)
|
||||
}
|
||||
|
||||
func TestDefaultFilled(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
||||
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
Release: config.Release{
|
||||
GitHub: config.Repo{
|
||||
Name: "foo",
|
||||
Owner: "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.NoError(t, Pipe{}.Default(ctx))
|
||||
assert.Equal(t, "foo", ctx.Config.Release.GitHub.Name)
|
||||
assert.Equal(t, "bar", ctx.Config.Release.GitHub.Owner)
|
||||
}
|
||||
|
||||
func TestDefaultNotAGitRepo(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.Error(t, Pipe{}.Default(ctx))
|
||||
assert.Empty(t, ctx.Config.Release.GitHub.String())
|
||||
}
|
||||
|
||||
func TestDefaultGitRepoWithoutRemote(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.Error(t, Pipe{}.Default(ctx))
|
||||
assert.Empty(t, ctx.Config.Release.GitHub.String())
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
FailToCreateRelease bool
|
||||
FailToUpload bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user