forked from qdm12/gosplash
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgosplash_test.go
86 lines (78 loc) · 2.35 KB
/
gosplash_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
76
77
78
79
80
81
82
83
84
85
86
package gosplash
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func Test_MakeLines(t *testing.T) { //nolint:tparallel
t.Parallel()
const someUnix = 1000
const someUnixAfter = 1100
testCases := map[string]struct {
now time.Time
settings Settings
lines []string
}{
"empty settings": {
lines: []string{
"========================================",
"========================================",
"========================================",
"",
"Running version unknown built on unknown date (commit unknown)",
"",
},
},
"filled settings": {
now: time.Unix(someUnix, 0),
settings: Settings{
Format: DefaultFormat,
LineLength: 50,
Separator: '=',
User: "qdm12",
Repository: "gosplash",
Emails: []string{"[email protected]"},
Version: "v1.1.1",
Commit: "c892ef2",
BuildDate: "2021-07-14",
Announcement: "hello world",
AnnounceExp: time.Unix(someUnixAfter, 0),
PaypalUser: "qmcgaw",
GithubSponsor: "qdm12",
},
lines: []string{
"==================================================",
"==================================================",
"==================== gosplash ====================",
"==================================================",
"================ Made with ❤️ by =================",
"============ https://github.com/qdm12 ============",
"==================================================",
"==================================================",
"",
"Running version v1.1.1 built on 2021-07-14 (commit c892ef2)",
"",
"📣 hello world",
"",
"🔧 Need help? https://github.com/qdm12/gosplash/discussions/new",
"🐛 Bug? https://github.com/qdm12/gosplash/issues/new",
"✨ New feature? https://github.com/qdm12/gosplash/issues/new",
"☕ Discussion? https://github.com/qdm12/gosplash/discussions/new",
"💻 Email? [email protected]",
"💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12",
},
},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
timeNow = func() time.Time {
return testCase.now
}
defer func() {
timeNow = time.Now
}()
lines := MakeLines(testCase.settings)
assert.Equal(t, testCase.lines, lines)
})
}
}