forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_test.go
75 lines (71 loc) · 1.43 KB
/
version_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package op_service
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFormatVersion(t *testing.T) {
tests := []struct {
version string
gitCommit string
gitDate string
meta string
expected string
}{
{
version: "v1.0.0",
gitCommit: "c90a760cfaccefb60b942ffe4ccf4f9692587cec",
gitDate: "1698107786",
meta: "",
expected: "v1.0.0-c90a760c-1698107786",
},
{
version: "v1.0.0",
gitCommit: "dev",
gitDate: "1698107786",
meta: "",
expected: "v1.0.0-dev-1698107786",
},
{
version: "v1.0.0",
gitCommit: "",
gitDate: "1698107786",
meta: "",
expected: "v1.0.0-1698107786",
},
{
version: "v1.0.0",
gitCommit: "dev",
gitDate: "",
meta: "",
expected: "v1.0.0-dev",
},
{
version: "v1.0.0",
gitCommit: "",
gitDate: "",
meta: "rc.1",
expected: "v1.0.0-rc.1",
},
{
version: "v1.0.0",
gitCommit: "",
gitDate: "",
meta: "",
expected: "v1.0.0",
},
{
version: "v1.0.0",
gitCommit: "c90a760cfaccefb60b942ffe4ccf4f9692587cec",
gitDate: "1698107786",
meta: "beta",
expected: "v1.0.0-c90a760c-1698107786-beta",
},
}
for _, test := range tests {
test := test
t.Run(test.expected, func(t *testing.T) {
actual := FormatVersion(test.version, test.gitCommit, test.gitDate, test.meta)
require.Equal(t, test.expected, actual)
})
}
}