Skip to content

Commit

Permalink
Add a check for failing task - /bin/false is a failing task
Browse files Browse the repository at this point in the history
  • Loading branch information
cinek810 committed Feb 1, 2023
1 parent c168698 commit a3d06a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/02a-checkrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ check_run_ok "ansible-deployer run --task task_with_limit --stage testing --infr
check_run_ok "ansible-deployer run --task tagged_task_true --stage testing --infrastructure testInfra"
check_run_ok "ansible-deployer verify --task task_exec_bin_true --stage prod --infrastructure testInfra"
check_run_ok "ansible-deployer run --task skip_task_tagged_task_false --stage testing --infrastructure testInfra"
check_run_fail "ansible-deployer run --task tagged_task_false --stage testing --infrastructure testInfra"

echo -e " ___ ____ _ _\n / _ \___ \ __ _ ___| |__ ___ ___| | ___ __ _ _ _ __\n | | | |__) / _\` | _____ / __| '_ \ / _ \/ __| |/ / '__| | | | '_ \ \n | |_| / __/ (_| | |_____| | (__| | | | __/ (__| <| | | |_| | | | |\n \___/_____\__,_| \___|_| |_|\___|\___|_|\_\_| \__,_|_| |_|\n \n _ _ _ _ _ _\n (_)_ ____ ____ _| (_) __| | ___ _ __ | |_(_) ___ _ __ ___\n | | '_ \ \ / / _\` | | |/ _\` | / _ \| '_ \| __| |/ _ \| '_ \/ __|\n | | | | \ V / (_| | | | (_| | | (_) | |_) | |_| | (_) | | | \__ \ \n |_|_| |_|\_/ \__,_|_|_|\__,_| \___/| .__/ \__|_|\___/|_| |_|___/\n |_|\n"
# Non-existent option values
Expand Down
16 changes: 16 additions & 0 deletions tests/testing_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ check_run_ok() {
fi
}

check_run_fail() {
CMD=$1
echo "Check: $CMD"
$CMD
if [ $? -eq 0 ]
then
echo "FAILED(Expected failure got return code of 0): ${CMD}"
echo "$CMD"
eval "$CMD"
exit 1
else
echo "OK - failed as expected"
fi
}


check_message_in_output() {
CMD=$1
EXPTEXT=$2
Expand Down

0 comments on commit a3d06a4

Please # to comment.