mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
test: covered build api with tests
This commit is contained in:
parent
9416dcc751
commit
08bad12e11
@ -1,21 +1,42 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var emptyEnv []string
|
||||
|
||||
// func TestRun(t *testing.T) {
|
||||
// assert.NoError(t, Run(
|
||||
// context.New(config.Project{}),
|
||||
// buildtarget.Runtime,
|
||||
// []string{"go", "list", "./..."},
|
||||
// emptyEnv,
|
||||
// ))
|
||||
// }
|
||||
type dummy struct{}
|
||||
|
||||
// func TestRunInvalidCommand(t *testing.T) {
|
||||
// assert.Error(t, Run(
|
||||
// context.New(config.Project{}),
|
||||
// buildtarget.Runtime,
|
||||
// []string{"gggggo", "nope"},
|
||||
// emptyEnv,
|
||||
// ))
|
||||
// }
|
||||
func (*dummy) Default(build config.Build) config.Build {
|
||||
return build
|
||||
}
|
||||
func (*dummy) Build(ctx *context.Context, build config.Build, options Options) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestRegisterAndGet(t *testing.T) {
|
||||
var builder = &dummy{}
|
||||
Register("dummy", builder)
|
||||
assert.Equal(t, builder, For("dummy"))
|
||||
}
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
assert.NoError(t, Run(
|
||||
context.New(config.Project{}),
|
||||
[]string{"go", "list", "./..."},
|
||||
emptyEnv,
|
||||
))
|
||||
}
|
||||
|
||||
func TestRunInvalidCommand(t *testing.T) {
|
||||
assert.Error(t, Run(
|
||||
context.New(config.Project{}),
|
||||
[]string{"gggggo", "nope"},
|
||||
emptyEnv,
|
||||
))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user