Skip to content

Commit

Permalink
Trying to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjol authored Sep 1, 2024
1 parent 2e8df0c commit d844822
Showing 1 changed file with 30 additions and 38 deletions.
68 changes: 30 additions & 38 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -85,4 +77,4 @@ check_drupal_admin_access() {
# check_project_browse >&3
## Todo Make this test work
# check_drupal_admin_access >&3
#}
#}

0 comments on commit d844822

Please sign in to comment.