-
Notifications
You must be signed in to change notification settings - Fork 150
Meta: Add bashunit tests to CI workflow and implement a first test case #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ac132b7
Meta: Add bashunit tests to CI workflow and implement a first test ca…
carlfriedrich d5961be
Refactor: Move global code into a main function (#464)
carlfriedrich a27da47
Chore: Do not execute any code when forgit is sourced (#464)
carlfriedrich b244e34
Meta: Add unit test for _forgit_get_files_from_diff_line function (#464)
carlfriedrich d646d39
Refactor: extract function to remove status from diff line (#464)
carlfriedrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
._zinit/ | ||
*.zwc | ||
lib/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
function test_exit_when_fzf_is_not_installed() { | ||
# Error code 127 = "command not found" | ||
mock fzf "return 127" | ||
|
||
output=$(bin/git-forgit) | ||
|
||
assert_general_error | ||
assert_contains "fzf is not installed" "$output" | ||
} | ||
|
||
# @data_provider fzf_versions_below_required_version | ||
function test_exit_when_fzf_version_is_below_required_version() { | ||
mock "fzf" "echo '$1'" | ||
|
||
output=$(bin/git-forgit) | ||
|
||
assert_general_error | ||
assert_contains "fzf version 0.49.0 or higher is required" "$output" | ||
} | ||
|
||
function fzf_versions_below_required_version() { | ||
echo "0.0.2" | ||
echo "0.5.0" | ||
echo "0.30.0" | ||
echo "0.48.9" | ||
} | ||
|
||
# @data_provider fzf_versions_satisfying_required_version | ||
function test_pass_when_fzf_version_satisfies_required_version() { | ||
mock "fzf" "echo '$1'" | ||
|
||
output=$(bin/git-forgit) | ||
|
||
assert_general_error | ||
assert_contains "missing command" "$output" | ||
} | ||
|
||
function fzf_versions_satisfying_required_version() { | ||
echo "0.49.0" | ||
echo "0.49.1" | ||
echo "0.80.0" | ||
echo "1.1.0" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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\"" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.