summaryrefslogtreecommitdiff
path: root/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_user.test.fish
blob: 489983de164ca5accc5c1285bf4b09f3f8ccd227 (plain)
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
89
90
91
92
93
94
95
source $DIRNAME/spacefish_test_setup.fish

function setup
	spacefish_test_setup
end

function teardown
	set USER $LOGNAME
end

test "Displays user when different from logname"
	(
		set USER spacefishUser

		set_color --bold
		echo -n "with "
		set_color normal
		set_color --bold yellow
		echo -n "spacefishUser"
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_user)
end

test "Displays user when UID = 0"
	(
		set UID 0

		set_color --bold
		echo -n "with "
		set_color normal
		set_color --bold yellow
		echo -n $USER
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_user)
end

test "Displays user when there's an SSH connection"
	(
		set SSH_CONNECTION "192.168.0.100 12345 192.168.0.101 22"

		set_color --bold
		echo -n "with "
		set_color normal
		set_color --bold yellow
		echo -n $USER
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_user)
end

test "Changes user color when logged in as root"
	(
		set USER root

		set_color --bold
		echo -n "with "
		set_color normal
		set_color --bold red
		echo -n root
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_user)
end

test "Displays user when SPACEFISH_USER_SHOW is set to \"always\""
	(
		set SPACEFISH_USER_SHOW always

		set_color --bold
		echo -n "with "
		set_color normal
		set_color --bold yellow
		echo -n $USER
		set_color normal
		set_color --bold
		echo -n " "
		set_color normal
	) = (__sf_section_user)
end

test "Doesn't display user when SPACEFISH_USER_SHOW is set to \"false\""
	(
		set SPACEFISH_USER_SHOW false
	) = (__sf_section_user)
end