Skip to content

Commit

Permalink
add prepare-commit-msg test
Browse files Browse the repository at this point in the history
all credit goes to @kirkoman

Co-authored-by: Kirk McKelvey <kmckelvey@extensis.com>
  • Loading branch information
typicode and Kirk McKelvey committed Dec 11, 2020
1 parent 992c1e0 commit cbd0e06
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scripts/test-install.sh
Expand Up @@ -152,5 +152,37 @@ if [ "$exitCode" -eq 0 ]; then
exit 1
fi

# ---
test "hook should run and pass all HUSKY_GIT_PARAMS"
cat > .huskyrc << EOL
{
"skipCI": false,
"hooks": {
"prepare-commit-msg": "echo \"prepare-commit-msg hook from Husky\" && echo \$HUSKY_GIT_PARAMS > $hookParamsFile"
}
}
EOL
if [ -f $hookParamsFile ]; then
rm $hookParamsFile
fi

commit sixth

if [ ! -f $hookParamsFile ]; then
echo "Fail: hook script didn't run"
exit 1
fi

actual=$(cat $hookParamsFile)
expected=".git/COMMIT_EDITMSG message"

if [ "$actual" != "$expected" ]; then
echo "Fail: HUSKY_GIT_PARAMS weren't set correctly"
echo "$actual != $expected"
exit 1
fi

echo
echo "Success: all tests passed"


0 comments on commit cbd0e06

Please sign in to comment.