Skip to content

Commit

Permalink
Tests - move testing to a shell script
Browse files Browse the repository at this point in the history
This should be much easier to add more checks
  • Loading branch information
cinek810 committed Jan 28, 2022
1 parent a45de02 commit 7585bfa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 2 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ jobs:
- run:
command: "cat $(which ansible-deploy)"
- run:
name: "Simple exec"
command: ansible-deploy || if [ $? -eq 2 ]; then exit 0; fi
- run:
name: "Fail if run without tasks with exit 55"
command: ansible-deploy run || if [ $? -eq 55 ]; then exit 0; fi

name: "Run shell script for argument parsing"
command: ./tests/01-test_argument_parsing.sh

install_and_exec:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
Expand Down
19 changes: 19 additions & 0 deletions tests/01-test_argument_parsing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -l

check_output() {
CMD=$1
EXPTEXT=$2

eval "$CMD |& grep '$EXPTEXT'"
if [ $? -eq 0 ]
then
echo "OK: '${CMD} returned ${EXPTEXT}'"
else
echo "FAILED: '${CMD}' didn't return '${EXPTEXT}'"
exit 1
fi
}

check_output 'ansible-deploy' '\[ERROR\]: To fee arguments'
check_output 'ansible-deploy run' '\[ERROR\]: run requires --task'

0 comments on commit 7585bfa

Please sign in to comment.