mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
Default for binary_name
This commit is contained in:
parent
37034012c4
commit
eaafc0a46b
@ -27,6 +27,9 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
return errors.New("failed reading repo from Git: " + err.Error())
|
||||
}
|
||||
}
|
||||
if ctx.Config.BinaryName == "" {
|
||||
ctx.Config.BinaryName = strings.Split(ctx.Config.Repo, "/")[1]
|
||||
}
|
||||
if ctx.Config.Build.Main == "" {
|
||||
ctx.Config.Build.Main = "main.go"
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ func TestFillBasicData(t *testing.T) {
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
|
||||
assert.Equal("goreleaser/releaser", config.Repo)
|
||||
assert.Equal("releaser", config.BinaryName)
|
||||
assert.Equal("main.go", config.Build.Main)
|
||||
assert.Equal("tar.gz", config.Archive.Format)
|
||||
assert.Contains(config.Build.Oses, "darwin")
|
||||
|
@ -1,23 +0,0 @@
|
||||
package valid
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/goreleaser/releaser/context"
|
||||
)
|
||||
|
||||
// Pipe for brew deployment
|
||||
type Pipe struct{}
|
||||
|
||||
// Name of the pipe
|
||||
func (Pipe) Description() string {
|
||||
return "Validating configuration..."
|
||||
}
|
||||
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
if ctx.Config.BinaryName == "" {
|
||||
return errors.New("missing binary_name")
|
||||
}
|
||||
return
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package valid
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/releaser/config"
|
||||
"github.com/goreleaser/releaser/context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func runPipe(repo, bin string) error {
|
||||
var config = &config.ProjectConfig{
|
||||
Repo: repo,
|
||||
BinaryName: bin,
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Config: config,
|
||||
}
|
||||
return Pipe{}.Run(ctx)
|
||||
}
|
||||
|
||||
func TestValidadeMissingBinaryName(t *testing.T) {
|
||||
assert.Error(t, runPipe("a/b", ""))
|
||||
}
|
||||
|
||||
func TestValidadeMinimalConfig(t *testing.T) {
|
||||
assert.NoError(t, runPipe("", "a"))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user