1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/main_test.go
Carlos Alexandro Becker 9aeea7b430
feat: new --version output (#3962)
using the same output as most cloud-native Go-written CLI's use, i.e.
using
[sigs.k8s.io/release-utils](https://github.com/kubernetes-sigs/release-utils).

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2023-04-30 14:19:55 -03:00

44 lines
818 B
Go

package main
import (
"testing"
"github.com/goreleaser/goreleaser/internal/golden"
"github.com/stretchr/testify/require"
)
func TestVersion(t *testing.T) {
for name, tt := range map[string]struct {
version, commit, date, builtBy string
}{
"all empty": {},
"complete": {
version: "1.2.3",
date: "12/12/12",
commit: "aaaa",
builtBy: "me",
},
"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",
},
} {
tt := tt
t.Run(name, func(t *testing.T) {
v := buildVersion(tt.version, tt.commit, tt.date, tt.builtBy)
out, err := v.JSONString()
require.NoError(t, err)
golden.RequireEqualJSON(t, []byte(out))
})
}
}