mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-27 01:33:39 +02:00
ec2db4a727
<!-- Hi, thanks for contributing! Please make sure you read our CONTRIBUTING guide. Also, add tests and the respective documentation changes as well. --> <!-- If applied, this commit will... --> ... <!-- Why is this change being made? --> ... <!-- # Provide links to any relevant tickets, URLs or other resources --> ... --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/internal/golden"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestVersion(t *testing.T) {
|
|
const goVersion = "go1.20.3"
|
|
const compiler = "gc"
|
|
const platform = "linux/amd64"
|
|
|
|
for name, tt := range map[string]struct {
|
|
version, commit, date, builtBy, treeState string
|
|
}{
|
|
"all empty": {},
|
|
"complete": {
|
|
version: "1.2.3",
|
|
date: "12/12/12",
|
|
commit: "aaaa",
|
|
builtBy: "me",
|
|
treeState: "clean",
|
|
},
|
|
"only version": {
|
|
version: "1.2.3",
|
|
},
|
|
"version and date": {
|
|
version: "1.2.3",
|
|
date: "12/12/12",
|
|
},
|
|
"version, date, built by": {
|
|
version: "1.2.3",
|
|
date: "12/12/12",
|
|
builtBy: "me",
|
|
},
|
|
} {
|
|
t.Run(name, func(t *testing.T) {
|
|
v := buildVersion(tt.version, tt.commit, tt.date, tt.builtBy, tt.treeState)
|
|
v.GoVersion = goVersion
|
|
v.Compiler = compiler
|
|
v.Platform = platform
|
|
out, err := v.JSONString()
|
|
require.NoError(t, err)
|
|
|
|
golden.RequireEqualJSON(t, []byte(out))
|
|
})
|
|
}
|
|
}
|