diff --git a/test/test_image.sh b/test/test_image.sh index 239e0df..9740eb6 100755 --- a/test/test_image.sh +++ b/test/test_image.sh @@ -2,6 +2,9 @@ set -eu +declare -g EXCEPTED_DOC_BASE_PATH='/usr/share/nginx/html/octocat/hello-world' +declare -g VERBOSE='false' + root_dir=$(readlink -f $(dirname $(realpath "$0"))/..) if ! [ -f "$root_dir"/id_rsa ]; then echo 'Generating SSH key' @@ -34,10 +37,27 @@ run_image() { -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 run --rm -i -v codefirst-nginx:/usr/share/nginx busybox find /usr/share/nginx +} + +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 + 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 + fi + fi } docker build -t codefirst-docdeployer "$root_dir" docker build -t codefirst-nginx "$root_dir/test/nginx" -run_image main 'doxygen -g && /entrypoint.sh -b main -l . -t doxygen -d sourcecode_documentation' +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 +} + +test_doxygen