From d844822984ee1c62c06f67bb78d6a2e271204166 Mon Sep 17 00:00:00 2001 From: Juanjo Date: Sun, 1 Sep 2024 20:15:34 +0200 Subject: [PATCH] Trying to fix tests --- tests/test.bats | 68 ++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/tests/test.bats b/tests/test.bats index 5290a8e..be80c0e 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -4,66 +4,58 @@ setup() { set -eu -o pipefail export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.." export TESTDIR=~/tmp/test-addon-aljibe - mkdir -p $TESTDIR + mkdir -p "$TESTDIR" export PROJNAME=test-addon-aljibe export DDEV_NON_INTERACTIVE=true - ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true - cd "${TESTDIR}" - ddev config --project-name=${PROJNAME} + ddev delete -Oy "$PROJNAME" >/dev/null 2>&1 || true + cd "$TESTDIR" + ddev config --project-name="$PROJNAME" ddev start -y >/dev/null } teardown() { set -eu -o pipefail - cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) - ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 - [ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR} + cd "$TESTDIR" || { printf "unable to cd to %s\n" "$TESTDIR"; exit 1; } + ddev delete -Oy "$PROJNAME" >/dev/null 2>&1 + [ -n "$TESTDIR" ] && rm -rf "$TESTDIR" } check_services() { - echo -n "Checking services:" + echo "Checking services:" INSTALLED_SERVICES=$(ddev get --installed) - echo -n "Checking if Aljibe is installed..." - echo "$INSTALLED_SERVICES" | grep -q "aljibe" | echo " Ok." - echo -n "Checking if Aljibe Assistant is installed..." - echo "$INSTALLED_SERVICES" | grep -q "aljibe-assistant" | echo " Ok." - echo -n "Checking if Adminer is installed..." - echo "$INSTALLED_SERVICES" | grep -q "adminer" | echo " Ok." - echo -n "Checking if BackstopJS is installed..." - echo "$INSTALLED_SERVICES" | grep -q "backstopjs" | echo " Ok." - echo -n "Checking if lighthouse is installed..." - echo "$INSTALLED_SERVICES" | grep -q "lighthouse" | echo " Ok." - echo -n "Checking if mkdocs is installed..." - echo "$INSTALLED_SERVICES" | grep -q "mkdocs" | echo " Ok." - echo -n "Checking if pa11y is installed..." - echo "$INSTALLED_SERVICES" | grep -q "pa11y" | echo " Ok." - echo -n "Checking if redis is installed..." - echo "$INSTALLED_SERVICES" | grep -q "redis" | echo " Ok." - echo -n "Checking if selenium is installed..." - echo "$INSTALLED_SERVICES" | grep -q "selenium" | echo " Ok." - echo -n "Checking if unlighthouse is installed..." - echo "$INSTALLED_SERVICES" | grep -q "unlighthouse" | echo " Ok." - + for SERVICE in aljibe aljibe-assistant adminer backstopjs lighthouse mkdocs pa11y redis selenium unlighthouse; + do + if echo "$INSTALLED_SERVICES" | grep -q "$SERVICE"; then + echo "Checking if $SERVICE is installed... Ok." + else + echo "Checking if $SERVICE is installed... Not installed." + fi + done } -# Check if the project is browsable with wget check_project_browse() { echo -n "Checking if the project is browsable..." - curl -s https://${PROJNAME}.ddev.site | grep -q "Welcome" - echo " Ok." + if curl -s "https://${PROJNAME}.ddev.site" | grep -q "Welcome"; then + echo " Ok." + else + echo " Failed." + fi } check_drupal_admin_access() { echo -n "Checking if the Drupal admin is accessible..." - curl -sLb cookies $(ddev drush uli) | grep -q "The email address is not made public" - echo " Ok." + if curl -sLb cookies "$(ddev drush uli)" | grep -q "The email address is not made public"; then + echo " Ok." + else + echo " Failed." + fi } @test "install from directory" { set -eu -o pipefail - cd ${TESTDIR} + cd "$TESTDIR" echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 - ddev get ${DIR} + ddev get "${DIR}" ddev restart >/dev/null ddev aljibe-assistant --auto @@ -75,7 +67,7 @@ check_drupal_admin_access() { #@test "install from release" { # set -eu -o pipefail -# cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) +# cd "$TESTDIR" || { printf "unable to cd to %s\n" "$TESTDIR"; exit 1; } # echo "# ddev get metadrop/ddev-aljibe with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 # ddev get metadrop/ddev-aljibe # ddev restart >/dev/null @@ -85,4 +77,4 @@ check_drupal_admin_access() { # check_project_browse >&3 ## Todo Make this test work # check_drupal_admin_access >&3 -#} +#} \ No newline at end of file