-
Notifications
You must be signed in to change notification settings - Fork 1
/
version_test.go
55 lines (43 loc) · 1.29 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
package texd
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
)
func TestVersionData_Version(t *testing.T) {
subject := versionData{version: "1.0", isdev: "0"}
assert.Equal(t, "1.0 (release)", subject.Version())
subject.isdev = "1"
assert.Equal(t, "1.0 (development)", subject.Version())
}
func TestVersionData_PrintBanner(t *testing.T) {
subject := versionData{
version: "0.99-42-dirty",
isdev: "1",
commitat: "2022-04-01T12:34:56Z",
buildat: "2022-04-02T12:34:56Z",
commit: "c0ffee",
}
const expected = `
_____ _ _ ____ texd version 0.99-42-dirty (development)
| ____ \_/ | \ commit c0ffee
| |___ _/ \_ |___/ commit date 2022-04-01T12:34:56Z
|___ build date 2022-04-02T12:34:56Z
`
var actual bytes.Buffer
subject.PrintBanner(&actual)
assert.Equal(t, expected, actual.String())
}
func TestGlobals(t *testing.T) {
assert.True(t, Development())
assert.Equal(t, "development (development)", Version())
const expected = `
_____ _ _ ____ texd version development (development)
| ____ \_/ | \ commit HEAD
| |___ _/ \_ |___/ commit date unknown
|___ build date unknown
`
var actual bytes.Buffer
PrintBanner(&actual)
assert.Equal(t, expected, actual.String())
}