Skip to content

Commit

Permalink
Add a database and improved tests for drupal9
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Aug 24, 2023
1 parent 7e01723 commit b5da5a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions tests/drupal9.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ teardown() {
for source in $PROJECT_SOURCE ddev/ddev-platformsh; do
per_test_setup

ddev exec drush cr

run curl -L -s http://${PROJNAME}.ddev.site/
assert_output "this is a test of ddev-platformsh drupal9"

run ddev exec -s db 'echo ${DDEV_DATABASE}'
assert_output "mariadb:10.4"
run ddev exec "php --version | awk 'NR==1 { sub(/\.[0-9]+$/, \"\", \$2); print \$2 }'"
Expand All @@ -26,10 +31,11 @@ teardown() {
run jq -r .raw.docroot <describe.json
assert_output "web"

assert_equal $(ddev exec 'echo $PLATFORM_ROUTES | base64 -d | jq -r "keys[0]"') "https://${PROJNAME}.ddev.site/"
assert_equal $(ddev exec 'echo $PLATFORM_ROUTES | base64 -d | jq -r .[].production_url') "https://${PROJNAME}.ddev.site/"
assert_equal "$(ddev exec 'echo $PLATFORM_ROUTES | base64 -d | jq -r "keys[0]"')" "https://${PROJNAME}.ddev.site/"
ddev exec 'echo $PLATFORM_RELATIONSHIPS | base64 -d' >relationships.json
echo "# PLATFORM_RELATIONSHIPS=$(cat relationships.json)" >&3
ddev exec 'echo $PLATFORM_ROUTES | base64 -d' >routes.json
echo "# PLATFORM_ROUTES=$(cat routes.json)" >&3

assert_equal "$(jq -r .database[0].type <relationships.json)" "mariadb:10.4"
assert_equal "$(jq -r .database[0].username <relationships.json)" "db"
Expand Down
4 changes: 3 additions & 1 deletion tests/per_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ per_test_setup() {
rm -rf ${TESTDIR} && mkdir -p ${TESTDIR} && cd ${TESTDIR}
curl -sfL -o /tmp/testtemplate.tgz "https://github.com/platformsh-templates/${template}/tarball/master"
tar -zxf /tmp/testtemplate.tgz --strip-components=1
# If the template happens to have a .ddev directory, remove as it can break things
rm -rf .ddev
# Start with bogus settings so we know we got the right stuff when testing
ddev config --project-name=${PROJNAME} --php-version=5.6 --database=mariadb:10.1 --docroot=x --create-docroot --project-type=php --web-environment-add=PLATFORMSH_CLI_TOKEN=notokenrightnow,PLATFORM_PROJECT=notyet,PLATFORM_ENVIRONMENT=notyet
echo "# doing ddev get $source with template ${template} PROJNAME=${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${PROJECT_SOURCE}
echo "# doing ddev restart with template ${template} PROJNAME=${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev restart >/dev/null
if [ -f ${PROJECT_SOURCE}/tests/testdata/${template}/db.sql.gz ]; then
ddev import-db --src=${PROJECT_SOURCE}/tests/testdata/${template}/db.sql.gz
ddev import-db --file=${PROJECT_SOURCE}/tests/testdata/${template}/db.sql.gz
fi
}

Expand Down
Binary file added tests/testdata/drupal9/db.sql.gz
Binary file not shown.

0 comments on commit b5da5a9

Please sign in to comment.