Skip to content

Commit

Permalink
Rename testtee to perform-verbose
Browse files Browse the repository at this point in the history
This change should improve readability of test scripts.
  • Loading branch information
extsoft committed Sep 30, 2019
1 parent d012ec3 commit 7a5bd5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Also, there are several optional addons which can be useful in some circumstance
#### Writing tests
1. **Use `setup()` or `teardown()`** bats methods only in the tests.
2. Use **`check` instead of bats `run`** to execute a command to be tested.
3. Use **`testtee`** to execute any real command within a test which should not be tested.
3. Use **`perform-verbose`** to execute any real command within a test which should not be tested.
4. If `addons-fake` or `addons-repo` is used, call `fake-clean` or `repo-clean` within a `teardown()` method.
5. Do not fake `git-elegant` commands within the tests.

Expand Down
4 changes: 2 additions & 2 deletions tests/addons-common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ check(){
done
}

testtee() {
perform-verbose() {
# Prints given command and executes it.
# It's useful as when a test is failed,
# then you can see a command in the log.
#
# usage: testtee [ags]...
# usage: perform-verbose [ags]...
echo "$(basename ${BASH_SOURCE[0]}): $@"
eval "$@"
}
26 changes: 13 additions & 13 deletions tests/addons-repo.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ FILE_TO_MODIFY=file

repo-new() {
if [[ -n "${GIT_REPO_DIR}" ]]; then
testtee mkdir -p ${GIT_REPO_DIR}
testtee cd ${GIT_REPO_DIR}
testtee git init
testtee git config --local user.email "\"[email protected]\""
testtee git config --local user.name "\"Elegant Git\""
testtee git config --local core.editor "\"edi\""
testtee touch ${FILE_TO_MODIFY}
testtee git add .
testtee git commit -m "\"Add ${FILE_TO_MODIFY}\""
perform-verbose mkdir -p ${GIT_REPO_DIR}
perform-verbose cd ${GIT_REPO_DIR}
perform-verbose git init
perform-verbose git config --local user.email "\"[email protected]\""
perform-verbose git config --local user.name "\"Elegant Git\""
perform-verbose git config --local core.editor "\"edi\""
perform-verbose touch ${FILE_TO_MODIFY}
perform-verbose git add .
perform-verbose git commit -m "\"Add ${FILE_TO_MODIFY}\""
else
exit 1
fi
Expand All @@ -23,21 +23,21 @@ repo-new() {
repo-non-staged-change(){
# modifies committed file
# usage: repo-non-staged-change <text>...
testtee "echo -e \"${@}\" >> ${FILE_TO_MODIFY}"
perform-verbose "echo -e \"${@}\" >> ${FILE_TO_MODIFY}"
}

repo-staged-change(){
# modifies committed file and stages changes
# usage: repo-staged-change <text>...
repo-non-staged-change "${@}"
testtee git add ${FILE_TO_MODIFY}
perform-verbose git add ${FILE_TO_MODIFY}
}

repo() {
# execute given arguments on real git repo
# usage: repo <command and arguments>
testtee cd ${GIT_REPO_DIR}
testtee "${@}"
perform-verbose cd ${GIT_REPO_DIR}
perform-verbose "${@}"
}

repo-clean() {
Expand Down

0 comments on commit 7a5bd5b

Please sign in to comment.