mirror of
https://github.com/jcwimer/startup-infrastructure
synced 2026-03-24 22:34:42 +00:00
Get skeleton testing in place
This commit is contained in:
21
tests/lib/test-function.sh
Normal file
21
tests/lib/test-function.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
red=`tput setaf 1`
|
||||
green=`tput setaf 2`
|
||||
reset=`tput sgr0`
|
||||
#echo "${red}red text ${green}green text${reset}"
|
||||
|
||||
function test {
|
||||
local name="${1}"
|
||||
shift
|
||||
local command="${@}"
|
||||
eval $command
|
||||
local return=$?
|
||||
if [[ ! $return -eq 0 ]]; then
|
||||
echo "${red}FAILED: ${name}${reset}"
|
||||
return 1
|
||||
else
|
||||
echo "${green}PASSED: $name${reset}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
27
tests/vagrant-tests.sh
Normal file
27
tests/vagrant-tests.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))"
|
||||
source ${project_dir}/tests/lib/test-function.sh
|
||||
|
||||
function main {
|
||||
cd ${project_dir}
|
||||
run-tests
|
||||
destroy-infrastructure
|
||||
}
|
||||
function run-tests {
|
||||
trap "destroy-infrastructure; exit 1" ERR
|
||||
echo Building vagrant infrastructure
|
||||
test "Building infrastructure with vagrant up should not fail." \
|
||||
"vagrant up > /dev/null"
|
||||
|
||||
test "Running command on a vagrant node should not fail." \
|
||||
vagrant ssh bootstrap -c ls
|
||||
}
|
||||
|
||||
function destroy-infrastructure {
|
||||
echo Tearing down vagrant infrastructure
|
||||
vagrant destroy -f > /dev/null
|
||||
}
|
||||
|
||||
main
|
||||
exit 0
|
||||
Reference in New Issue
Block a user