2018-02-21 20:04:22 -03:00
|
|
|
package main
|
2017-04-21 15:25:32 -03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-04-30 14:19:55 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/golden"
|
2019-05-27 23:59:33 -03:00
|
|
|
"github.com/stretchr/testify/require"
|
2017-04-21 15:25:32 -03:00
|
|
|
)
|
|
|
|
|
2019-05-27 23:59:33 -03:00
|
|
|
func TestVersion(t *testing.T) {
|
|
|
|
for name, tt := range map[string]struct {
|
|
|
|
version, commit, date, builtBy string
|
|
|
|
}{
|
2023-04-30 14:19:55 -03:00
|
|
|
"all empty": {},
|
2019-05-27 23:59:33 -03:00
|
|
|
"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) {
|
2023-04-30 14:19:55 -03:00
|
|
|
v := buildVersion(tt.version, tt.commit, tt.date, tt.builtBy)
|
|
|
|
out, err := v.JSONString()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
golden.RequireEqualJSON(t, []byte(out))
|
2019-05-27 23:59:33 -03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|