-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple_spec.sh
70 lines (63 loc) · 1.85 KB
/
simple_spec.sh
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
#shellcheck shell=bash
Describe 'check-pots.sh'
Include ./check-pots.sh
prepare() { pot='test'; }
Before 'prepare'
Describe 'check_tree()'
It 'Does not output a warning if the given tree exists'
tree_name='some_tree'
mkdir $tree_name
When call check_tree $tree_name
The output should not include 'was not found'
rm -fr $tree_name
End
It 'Outputs a warning if the given tree does not exist'
tree_name='some_tree'
When call check_tree $tree_name
The output should include 'was not found'
End
It 'Outputs a debug message if the given tree is empty'
tree_name='some_tree'
mkdir $tree_name
When call check_tree 'some_tree'
The output should include 'is empty'
rm -fr $tree_name
End
It 'Has no output if the tree is populated'
tree_name='some_tree'
mkdir $tree_name
touch ${tree_name}/abc
When call check_tree 'some_tree'
The output should be blank
rm -fr $tree_name
End
End
Describe 'check_pot()'
It 'Should emit a warning if sshd is disabled'
check_tree() { :; }
pot_exec() {
case $3 in
sysrc) echo 'NO';;
which) echo '/usr/sbin/pkg64';;
esac
}
When call check_pot
The lines of output should equal 1
The output should include 'sshd is disabled on'
End
It 'Should emit a warning if pkg binaries cannot be found'
check_tree() { :; }
pot_exec() {
case $3 in
sysrc) echo '';;
which) echo '';;
esac
}
When call check_pot
The lines of output should equal 3
The line 1 of output should include "pkg64 on $pot was not found"
The line 2 of output should include "pkg64c on $pot was not found"
The line 3 of output should include "pk64cb on $pot was not found"
End
End
End