forked from goreleaser/goreleaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
45 lines (42 loc) · 927 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestVersion(t *testing.T) {
for name, tt := range map[string]struct {
version, commit, date, builtBy string
out string
}{
"all empty": {
out: "",
},
"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",
},
"only version": {
version: "1.2.3",
out: "1.2.3",
},
"version and date": {
version: "1.2.3",
date: "12/12/12",
out: "1.2.3\nbuilt at: 12/12/12",
},
"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",
},
} {
tt := tt
t.Run(name, func(t *testing.T) {
require.Equal(t, tt.out, buildVersion(tt.version, tt.commit, tt.date, tt.builtBy))
})
}
}