|
|
|
@ -36,17 +36,44 @@ run_image() {
|
|
|
|
|
--rm codefirst-docdeployer \
|
|
|
|
|
-c "sed -i 's/ssh/ssh -p 2222/g' /entrypoint.sh && sed -i 's/root@nginx/codefirst@nginx/g' /entrypoint.sh && $*"
|
|
|
|
|
docker stop "$nginx_id"
|
|
|
|
|
docker volume rm codefirst-docdeployer-drone codefirst-docdeployer-docs
|
|
|
|
|
docker volume rm codefirst-docdeployer-drone codefirst-docdeployer-docs > /dev/null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check_on_deployed() {
|
|
|
|
|
# Run the given command on the codefirst-nginx volume.
|
|
|
|
|
docker run --rm -i -v codefirst-nginx:/usr/share/nginx busybox $*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
|
# Remove the codefirst-nginx volume after a test.
|
|
|
|
|
docker volume rm codefirst-nginx > /dev/null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert_file_exists() {
|
|
|
|
|
# Assert that the given file exists in the codefirst-nginx volume.
|
|
|
|
|
if docker run --rm -i -v codefirst-nginx:/usr/share/nginx busybox test -f "$EXCEPTED_DOC_BASE_PATH/$1"; then
|
|
|
|
|
if check_on_deployed test -f "$EXCEPTED_DOC_BASE_PATH/$1"; then
|
|
|
|
|
echo -e "$1 exists: \e[32mOK\e[0m"
|
|
|
|
|
else
|
|
|
|
|
echo -e "$1 does not exist: \e[31mFAILED\e[0m"
|
|
|
|
|
if [[ "$VERBOSE" = 'true' ]]; then
|
|
|
|
|
docker run --rm -i -v codefirst-nginx:/usr/share/nginx busybox find /usr/share/nginx
|
|
|
|
|
if [[ "$VERBOSE" == 'true' ]]; then
|
|
|
|
|
check_on_deployed find /usr/share/nginx
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert_file_contains() {
|
|
|
|
|
# Assert that the given file contains the given string.
|
|
|
|
|
if check_on_deployed grep -q $2 "$EXCEPTED_DOC_BASE_PATH/$1"; then
|
|
|
|
|
echo -e "$1 exists and matches content: \e[32mOK\e[0m"
|
|
|
|
|
elif check_on_deployed test -f "$EXCEPTED_DOC_BASE_PATH/$1"; then
|
|
|
|
|
echo -e "$1 exists but does not match content: \e[31mFAILED\e[0m"
|
|
|
|
|
if [[ "$VERBOSE" == 'true' ]]; then
|
|
|
|
|
check_on_deployed cat "$EXCEPTED_DOC_BASE_PATH/$1"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo -e "$1 does not exist: \e[31mFAILED\e[0m"
|
|
|
|
|
if [[ "$VERBOSE" == 'true' ]]; then
|
|
|
|
|
check_on_deployed find /usr/share/nginx
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
@ -57,7 +84,15 @@ docker build -t codefirst-nginx "$root_dir/test/nginx"
|
|
|
|
|
test_doxygen() {
|
|
|
|
|
run_image main 'doxygen -g > /dev/null && /entrypoint.sh -b main -l . -t doxygen -d sourcecode_documentation'
|
|
|
|
|
assert_file_exists sourcecode_documentation/doxygen/index.html
|
|
|
|
|
docker volume rm codefirst-nginx
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_swagger() {
|
|
|
|
|
run_image main 'touch api.yaml && /entrypoint.sh --type swagger --loc api.yaml'
|
|
|
|
|
assert_file_exists swagger/api.yaml
|
|
|
|
|
assert_file_contains swagger/CLICKME.html '/swagger?url=/documentation/octocat/hello-world/swagger/api.yaml'
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_doxygen
|
|
|
|
|
test_swagger
|
|
|
|
|