1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/build/name_test.go

45 lines
874 B
Go
Raw Normal View History

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