mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
Meta: Add bashunit tests to CI workflow and implement a first test case (#464)
This commit is contained in:
parent
5d4d6121b1
commit
ac132b7bba
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
- [ ] I have performed a self-review of my code
|
||||
- [ ] I have commented my code in hard-to-understand areas
|
||||
- [ ] I have added unit tests for my code
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
|
||||
## Description
|
||||
|
|
@ -18,6 +19,7 @@
|
|||
- [ ] New feature
|
||||
- [ ] Refactor
|
||||
- [ ] Breaking change
|
||||
- [ ] Test
|
||||
- [ ] Documentation change
|
||||
|
||||
## Test environment
|
||||
|
|
|
|||
6
.github/workflows/ci.yaml
vendored
6
.github/workflows/ci.yaml
vendored
|
|
@ -39,16 +39,22 @@ 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
|
||||
|
||||
- name: Show version
|
||||
run: |
|
||||
bash --version; echo
|
||||
zsh --version; echo
|
||||
fish --version; echo
|
||||
shellcheck --version; echo
|
||||
lib/bashunit --version; echo
|
||||
|
||||
- name: Shellcheck
|
||||
run: shellcheck forgit.plugin.sh bin/git-forgit
|
||||
|
||||
- name: Unit tests
|
||||
run: lib/bashunit .
|
||||
|
||||
- name: Test bash
|
||||
run: bash forgit.plugin.sh
|
||||
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
._zinit/
|
||||
*.zwc
|
||||
lib/
|
||||
|
|
|
|||
45
tests/fzf.test.sh
Normal file
45
tests/fzf.test.sh
Normal file
|
|
@ -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"
|
||||
}
|
||||
Loading…
Reference in a new issue