2017-01-14 19:08:10 +02:00
|
|
|
package build
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-01-15 00:01:32 +02:00
|
|
|
"github.com/goreleaser/goreleaser/config"
|
|
|
|
"github.com/goreleaser/goreleaser/context"
|
2017-01-14 19:08:10 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestExtWindows(t *testing.T) {
|
|
|
|
assert.Equal(t, extFor("windows"), ".exe")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestExtOthers(t *testing.T) {
|
|
|
|
assert.Empty(t, extFor("linux"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNameFor(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2017-01-18 19:08:48 +02:00
|
|
|
var config = config.Project{
|
2017-01-15 18:53:24 +02:00
|
|
|
Archive: config.Archive{
|
2017-01-14 19:08:10 +02:00
|
|
|
NameTemplate: "{{.BinaryName}}_{{.Os}}_{{.Arch}}_{{.Version}}",
|
|
|
|
Replacements: map[string]string{
|
|
|
|
"darwin": "Darwin",
|
|
|
|
"amd64": "x86_64",
|
|
|
|
},
|
|
|
|
},
|
2017-01-15 18:53:24 +02:00
|
|
|
Build: config.Build{
|
2017-01-14 23:52:39 +02:00
|
|
|
BinaryName: "test",
|
|
|
|
},
|
2017-01-14 19:08:10 +02:00
|
|
|
}
|
|
|
|
var ctx = &context.Context{
|
|
|
|
Config: config,
|
2017-01-18 19:08:48 +02:00
|
|
|
Git: context.GitInfo{
|
2017-01-14 19:08:10 +02:00
|
|
|
CurrentTag: "v1.2.3",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
name, err := nameFor(ctx, "darwin", "amd64")
|
|
|
|
assert.NoError(err)
|
|
|
|
assert.Equal("test_Darwin_x86_64_v1.2.3", name)
|
|
|
|
}
|