-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathconfiguration_test.go
88 lines (74 loc) · 2.13 KB
/
configuration_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
87
88
package testza
import (
"testing"
"time"
"github.com/MarvinJWendt/testza/internal"
"github.com/pterm/pterm"
)
func TestSetColorsEnabled(t *testing.T) {
t.Run("Disable", func(t *testing.T) {
SetColorsEnabled(false)
AssertFalse(t, pterm.PrintColor)
AssertFalse(t, GetColorsEnabled())
})
t.Run("Enable", func(t *testing.T) {
SetColorsEnabled(true)
AssertTrue(t, pterm.PrintColor)
AssertTrue(t, GetColorsEnabled())
})
}
func TestSetLineNumbersEnabled(t *testing.T) {
t.Run("Disable", func(t *testing.T) {
SetLineNumbersEnabled(false)
AssertFalse(t, internal.LineNumbersEnabled)
AssertFalse(t, GetLineNumbersEnabled())
})
t.Run("Enable", func(t *testing.T) {
SetLineNumbersEnabled(true)
AssertTrue(t, internal.LineNumbersEnabled)
AssertTrue(t, GetLineNumbersEnabled())
})
}
func TestSetRandomSeed(t *testing.T) {
SetRandomSeed(1337)
AssertEqual(t, int64(1337), randomSeed)
AssertEqual(t, int64(1337), GetRandomSeed())
AssertEqual(t, "4U390O49B9", FuzzStringGenerateRandom(1, 10)[0])
un := time.Now().UnixNano()
SetRandomSeed(un)
AssertEqual(t, un, randomSeed)
AssertEqual(t, un, GetRandomSeed())
}
func TestSetShowStartupMessage(t *testing.T) {
t.Run("Default is true", func(t *testing.T) {
AssertTrue(t, showStartupMessage)
AssertTrue(t, GetShowStartupMessage())
})
t.Run("Set to false", func(t *testing.T) {
SetShowStartupMessage(false)
AssertFalse(t, showStartupMessage)
AssertFalse(t, GetShowStartupMessage())
})
t.Run("Set to true", func(t *testing.T) {
SetShowStartupMessage(true)
AssertTrue(t, showStartupMessage)
AssertTrue(t, GetShowStartupMessage())
})
}
func TestSetEqualContextLineCount(t *testing.T) {
t.Run("Default is 2", func(t *testing.T) {
AssertEqual(t, 2, internal.DiffContextLines)
AssertEqual(t, 2, GetDiffContextLines())
})
t.Run("Set to -1", func(t *testing.T) {
SetDiffContextLines(-1)
AssertEqual(t, -1, internal.DiffContextLines)
AssertEqual(t, -1, GetDiffContextLines())
})
t.Run("Set to 3", func(t *testing.T) {
SetDiffContextLines(3)
AssertEqual(t, 3, internal.DiffContextLines)
AssertEqual(t, 3, GetDiffContextLines())
})
SetDiffContextLines(2)
}