1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00
goreleaser/main_test.go

49 lines
1.1 KiB
Go
Raw Normal View History

package main
2017-04-21 20:25:32 +02:00
import (
"fmt"
"runtime"
2017-04-21 20:25:32 +02:00
"testing"
"github.com/stretchr/testify/require"
2017-04-21 20:25:32 +02:00
)
func TestVersion(t *testing.T) {
os := fmt.Sprintf("\ngoos: %s\ngoarch: %s", runtime.GOOS, runtime.GOARCH)
for name, tt := range map[string]struct {
version, commit, date, builtBy string
out string
}{
"all empty": {
out: os + website,
},
"complete": {
version: "1.2.3",
date: "12/12/12",
commit: "aaaa",
builtBy: "me",
out: "1.2.3\ncommit: aaaa\nbuilt at: 12/12/12\nbuilt by: me" + os + website,
},
"only version": {
version: "1.2.3",
out: "1.2.3" + os + website,
},
"version and date": {
version: "1.2.3",
date: "12/12/12",
out: "1.2.3\nbuilt at: 12/12/12" + os + website,
},
"version, date, built by": {
version: "1.2.3",
date: "12/12/12",
builtBy: "me",
out: "1.2.3\nbuilt at: 12/12/12\nbuilt by: me" + os + website,
},
} {
tt := tt
t.Run(name, func(t *testing.T) {
require.Equal(t, tt.out, buildVersion(tt.version, tt.commit, tt.date, tt.builtBy))
})
}
}