Skip to content

Commit

Permalink
Read available commands dynamically
Browse files Browse the repository at this point in the history
`git elegant commands` will read commands dynamically. This change
allows having more stable results of other tests as the `commands`
command is often used in other commands or tests. For instance,
if we add a new command, it will be found automatically and
1. a help will be verified for it
2. `tests/git-elegant-commands.bats` will fail by requiring updates with
the data about the new command.

#118
  • Loading branch information
extsoft committed Sep 11, 2019
1 parent 10594a7 commit 98a0ed8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
15 changes: 4 additions & 11 deletions libexec/git-elegant-commands
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ MESSAGE
}

default() {
echo "acquire-repository"
echo "clone-repository"
echo "init-repository"
echo "start-work"
echo "save-work"
echo "deliver-work"
echo "accept-work"
echo "obtain-work"
echo "clear-local"
echo "commands"
echo "amend-work"
local PREFIX="git-elegant-"
for FILE in $(ls -1 ${BINS}/${PREFIX}*); do
echo $(basename ${FILE} | sed "s/${PREFIX}//")
done
}
6 changes: 3 additions & 3 deletions tests/git-elegant-commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ teardown() {
"amend-work"
)
check git-elegant commands
for command in {0..12}; do
[ "${lines[$command]}" = "${COMMANDS[$command]}" ]
[ ${#lines[@]} -eq ${#COMMANDS[@]} ]
for command in ${COMMANDS[@]}; do
[[ "${lines[@]}" =~ "${command}" ]]
done
[ ${#lines[@]} -eq 11 ]
}

@test "'commands': default exit code is 0" {
Expand Down

0 comments on commit 98a0ed8

Please sign in to comment.