-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathdoubles_test.sh
More file actions
64 lines (48 loc) · 1.45 KB
/
doubles_test.sh
File metadata and controls
64 lines (48 loc) · 1.45 KB
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
#!/bin/bash
function test_mock_ps_when_executing_a_script() {
mock ps cat ./tests/functional/fixtures/doubles_ps_output
assert_match_snapshot "$(source ./tests/functional/fixtures/doubles_script.sh)"
}
function test_mock_ps_when_executing_a_sourced_function() {
source ./tests/functional/fixtures/doubles_function.sh
mock ps cat ./tests/functional/fixtures/doubles_ps_output
assert_match_snapshot "$(top_mem)"
}
function test_spy_commands_called_when_executing_a_script() {
spy ps
spy awk
spy head
./tests/functional/fixtures/doubles_script.sh
assert_have_been_called ps
assert_have_been_called awk
assert_have_been_called head
}
function test_spy_commands_called_when_executing_a_sourced_function() {
source ./tests/functional/fixtures/doubles_function.sh
spy ps
spy awk
spy head
top_mem
assert_have_been_called ps
assert_have_been_called awk
assert_have_been_called head
}
function test_spy_commands_called_once_when_executing_a_script() {
spy ps
spy awk
spy head
./tests/functional/fixtures/doubles_script.sh
assert_have_been_called_times 1 ps
assert_have_been_called_times 1 awk
assert_have_been_called_times 1 head
}
function test_spy_commands_called_once_when_executing_a_sourced_function() {
source ./tests/functional/fixtures/doubles_function.sh
spy ps
spy awk
spy head
top_mem
assert_have_been_called_times 1 ps
assert_have_been_called_times 1 awk
assert_have_been_called_times 1 head
}