-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsum_and_count_existing.bats
54 lines (41 loc) · 1012 Bytes
/
sum_and_count_existing.bats
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
#!/usr/bin/env bats
load ../src/functions
load test-data
load test-helpers
load test-mocks
# Mock
load mocks/list
# Mock
does_exist() {
sed 's/.*t.*/1/; s/^[^1].*/0/;'
}
@test "should count existing files" {
# Given:
mocks_setup list
list_files=without-blanks
# When:
run sum_and_count_existing files of: com.example.plop.Pkg.ID with: /pfx/dir
# Then:
mocks_fetch_args
[ ${#args[@]} -eq 5 ]
[ "${args[0]}" == files ]
[ "${args[2]}" == com.example.plop.Pkg.ID ]
[ "${args[4]}" == /pfx/dir ]
[ "$output" == "$(echo -e "2\t3")" ]
[ $status -eq 0 ]
}
@test "should count existing files, supporting white spaces" {
# Given:
mocks_setup list
list_files=with-blanks
# When:
run sum_and_count_existing files of: com.example.plop.Pkg.ID with: "/pfx\t/ dir"
# Then:
mocks_fetch_args
[ ${#args[@]} -eq 5 ]
[ "$output" == "$(echo -e "2\t3")" ]
[ $status -eq 0 ]
}
# Local Variables:
# indent-tabs-mode: nil
# End: