32273fbf28
In commit 15723008062b941b53743295784554b2f3ba875e of PR #5311 the "git lfs completion" command was introduced, utilizing the support provided by the spf13/cobra package to generate tab-completion scripts for a number of shells, including the Bash, fish, and Zsh shells. No tests were added at the same time, however, so we do so now. The new tests are simple and just confirm that the "git lfs completion" command generates the expected error messages if it is not given an expected shell name as an argument, and that when one of the supported shell names is provided, the command generates the expected script. We do not attempt to test the functionality of the generated scripts. Although these tests are quite basic, they should help alert us to any potential regressions caused by an upgrade of the spf13/cobra package. In particular, if the scripts generated by that package for the Bash or Zsh shells change such that the search-and-replace operations we perform on the scripts cease to function, the "git lfs completion" command will still succeed but may produce a script which no longer integrates well with the tab-completion scripts for Git itself. Since we have now have archived copies of the current scripts as test fixtures, the tests will fail when the generated scripts are different. This should alert us to the fact that we need to check the new script output and confirm that it still works with Git tab-completion on the affected shells, and if not, revise our search-and-replace operations accordingly.
46 lines
781 B
Bash
Executable File
46 lines
781 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
. "$(dirname "$0")/testlib.sh"
|
|
|
|
begin_test "completion: bash script"
|
|
(
|
|
set -e
|
|
|
|
git lfs completion bash | cmp - "$COMPLETIONSDIR/git-lfs-completion.bash"
|
|
)
|
|
end_test
|
|
|
|
begin_test "completion: fish script"
|
|
(
|
|
set -e
|
|
|
|
git lfs completion fish | cmp - "$COMPLETIONSDIR/git-lfs-completion.fish"
|
|
)
|
|
end_test
|
|
|
|
begin_test "completion: zsh script"
|
|
(
|
|
set -e
|
|
|
|
git lfs completion zsh | cmp - "$COMPLETIONSDIR/git-lfs-completion.zsh"
|
|
)
|
|
end_test
|
|
|
|
begin_test "completion: missing shell argument"
|
|
(
|
|
set -e
|
|
|
|
git lfs completion 2>&1 | tee completion.log
|
|
grep "accepts 1 arg" completion.log
|
|
)
|
|
end_test
|
|
|
|
begin_test "completion: invalid shell argument"
|
|
(
|
|
set -e
|
|
|
|
git lfs completion ksh 2>&1 | tee completion.log
|
|
grep "invalid argument" completion.log
|
|
)
|
|
end_test
|