-
Notifications
You must be signed in to change notification settings - Fork 1
/
env_test.go
80 lines (71 loc) · 2 KB
/
env_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
package logy
import (
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestSupportsColor_IfItIsWslDistro(t *testing.T) {
os.Clearenv()
os.Setenv("WSL_DISTRO_NAME", "anyWslDistroName")
assert.False(t, supportsColor())
}
func TestSupportsColor_ReturnTrueIfItIsJetBrainsTerminal(t *testing.T) {
os.Clearenv()
os.Setenv("TERM", "notScreen")
os.Setenv("TERMINAL_EMULATOR", "JetBrains-JediTerm")
assert.True(t, supportsColor())
}
func TestSupportsColor_IfItIsSpecialTerm(t *testing.T) {
os.Clearenv()
os.Setenv("TERM", "screen")
os.Setenv("TERMINAL_EMULATOR", "")
os.Setenv("COLORTERM", "")
os.Setenv("TERM_PROGRAM", "")
os.Setenv("FORCE_COLOR", "")
assert.True(t, supportsColor())
}
func TestSupportsColor_IfItIsAppleTerminal(t *testing.T) {
os.Clearenv()
os.Setenv("TERM", "screen")
os.Setenv("TERMINAL_EMULATOR", "")
os.Setenv("COLORTERM", "")
os.Setenv("TERM_PROGRAM", "Apple_Terminal")
os.Setenv("FORCE_COLOR", "")
assert.True(t, supportsColor())
}
func TestSupportsColor_IfItIsTerminus(t *testing.T) {
os.Clearenv()
os.Setenv("TERM", "screen")
os.Setenv("TERMINAL_EMULATOR", "")
os.Setenv("COLORTERM", "")
os.Setenv("TERM_PROGRAM", "Terminus")
os.Setenv("FORCE_COLOR", "")
assert.True(t, supportsColor())
}
func TestSupportsColor_IfItIsHyper(t *testing.T) {
os.Clearenv()
os.Setenv("TERM", "screen")
os.Setenv("TERMINAL_EMULATOR", "")
os.Setenv("COLORTERM", "")
os.Setenv("TERM_PROGRAM", "Hyper")
os.Setenv("FORCE_COLOR", "")
assert.True(t, supportsColor())
}
func TestSupportsColor_IfItIsITerm(t *testing.T) {
os.Clearenv()
os.Setenv("TERM", "screen")
os.Setenv("TERMINAL_EMULATOR", "")
os.Setenv("COLORTERM", "")
os.Setenv("TERM_PROGRAM", "iTerm.app")
os.Setenv("FORCE_COLOR", "")
assert.True(t, supportsColor())
}
func TestSupportsColor_IfItIsTrueColor(t *testing.T) {
os.Clearenv()
os.Setenv("TERM", "screen")
os.Setenv("TERMINAL_EMULATOR", "")
os.Setenv("COLORTERM", "truecolor")
os.Setenv("TERM_PROGRAM", "")
os.Setenv("FORCE_COLOR", "")
assert.True(t, supportsColor())
}