-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathversion_test.go
42 lines (37 loc) · 916 Bytes
/
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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetVersionInfo(t *testing.T) {
buildArch = "ba"
buildBranch = "bb"
buildCompiler = "bc"
buildDate = "bd"
buildHash = "bh"
buildUser = "bu"
buildVersion = "bv"
v := getVersionInfo()
assert.Equal(t, "ba", v.Arch)
assert.Equal(t, "bb", v.Branch)
assert.Equal(t, "bc", v.Compiler)
assert.Equal(t, "bd", v.Date)
assert.Equal(t, "bh", v.Hash)
assert.Equal(t, "bu", v.User)
assert.Equal(t, "bv", v.Version)
}
func TestGetVersionInfoStringer(t *testing.T) {
buildArch = "ba"
buildBranch = "bb"
buildCompiler = "bc"
buildDate = "bd"
buildHash = "bh"
buildUser = "bu"
buildVersion = "bv"
s := getVersionInfo().String()
assert.Regexp(t, `Version:\s+bv`, s)
assert.Regexp(t, `Build time:\s+bd`, s)
assert.Regexp(t, `Build:\s+bu@bb:bh`, s)
assert.Regexp(t, `Compiler:\s+bc`, s)
assert.Regexp(t, `Arch:\s+ba`, s)
}