mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
Meta: Add unit test for _forgit_get_files_from_diff_line function (#464)
Update CI to install latest bashunit beta version instead of fixed 0.23.0 version because we need the new "data_set" function for parameterized tests.
This commit is contained in:
parent
ab6a63ee0f
commit
61d3192055
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
sudo apt -y update
|
||||
sudo apt -y install zsh fish shellcheck
|
||||
fi
|
||||
curl -s https://bashunit.typeddevs.com/install.sh | bash -s 0.23.0
|
||||
curl -s https://bashunit.typeddevs.com/install.sh | bash -s beta
|
||||
|
||||
- name: Show version
|
||||
run: |
|
||||
|
|
|
|||
33
tests/helper-functions.test.sh
Normal file
33
tests/helper-functions.test.sh
Normal file
|
|
@ -0,0 +1,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() {
|
||||
data_set "[A] newfile" "newfile"
|
||||
data_set "[D] oldfile with spaces" "oldfile with spaces"
|
||||
data_set "[R100] file -> another file" "file" "another file"
|
||||
data_set "[M] \"file with\ttab.txt\"" "\"file with\ttab.txt\""
|
||||
}
|
||||
Loading…
Reference in a new issue