-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathhelper-functions.test.sh
More file actions
33 lines (27 loc) · 941 Bytes
/
helper-functions.test.sh
File metadata and controls
33 lines (27 loc) · 941 Bytes
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
#!/usr/bin/env bash
function set_up_before_script() {
source bin/git-forgit
}
# @data_provider provider_diff_lines
function test_forgit_get_files_from_diff_line() {
local -r input="$1"
shift
local -r expected=("$@")
local -a actual=()
local i
while IFS= read -r line; do
actual+=("$line")
done < <(echo -n "$input" | _forgit_get_files_from_diff_line | xargs -0 -n 1 echo)
# Compare array sizes
assert_same "${#expected[@]}" "${#actual[@]}"
# Compare array elements
for i in "${!expected[@]}"; do
assert_same "${expected[i]}" "${actual[i]}"
done
}
function provider_diff_lines() {
bashunit::data_set "[A] newfile" "newfile"
bashunit::data_set "[D] oldfile with spaces" "oldfile with spaces"
bashunit::data_set "[R100] file -> another file" "file" "another file"
bashunit::data_set "[M] \"file with\ttab.txt\"" "\"file with\ttab.txt\""
}