1
0
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:
Carlos Alexandro Becker 2018-01-23 00:22:00 -02:00
parent 9416dcc751
commit 08bad12e11
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940

View File

@ -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,
))
}