Skip to content

Commit

Permalink
Add optional --redis-tag flag, fixes #1 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
stasadev authored Oct 17, 2024
1 parent cb16896 commit ce69968
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ This repository allows you to quickly install Redis into a [DDEV](https://ddev.r
1. `ddev get ddev/ddev-redis`
2. `ddev restart`

With DDEV v1.23.5+ you can choose a different Redis tag, the command below creates a `.ddev/.env.redis` file that you can commit:

1. `ddev dotenv set .ddev/.env.redis --redis-tag 7`
2. `ddev restart`

## Explanation

This Redis recipe for [DDEV](https://ddev.readthedocs.io) installs a [`.ddev/docker-compose.redis.yaml`](docker-compose.redis.yaml) using the `redis` Docker image.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
services:
redis:
container_name: ddev-${DDEV_SITENAME}-redis
image: redis:6-bullseye
image: redis:${REDIS_TAG:-6-bullseye}
# These labels ensure this service is discoverable by ddev.
labels:
com.ddev.site-name: ${DDEV_SITENAME}
Expand Down
31 changes: 23 additions & 8 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,59 @@ teardown() {
}

@test "basic installation" {
ddev config --project-name=${PROJNAME} --project-type=drupal9 --docroot=web --create-docroot
ddev config --project-name=${PROJNAME} --project-type=drupal --docroot=web
ddev start -y
cd ${TESTDIR}
ddev get ${DIR}
ddev add-on get ${DIR}
ddev restart
ddev redis-cli INFO | grep "^redis_version:6."
# Check if Redis configuration was setup.
[ -f web/sites/default/settings.ddev.redis.php ]
grep -F 'settings.ddev.redis.php' web/sites/default/settings.php
}

@test "basic installation with Redis tag 7" {
ddev config --project-name=${PROJNAME} --project-type=drupal --docroot=web
ddev start -y
cd ${TESTDIR}
ddev add-on get ${DIR}
ddev dotenv set .ddev/.env.redis --redis-tag=7
# Check if .env file for Redis exists.
[ -f .ddev/.env.redis ]
ddev restart
ddev redis-cli INFO | grep "^redis_version:7."
# Check if Redis configuration was setup.
[ -f web/sites/default/settings.ddev.redis.php ]
grep -F 'settings.ddev.redis.php' web/sites/default/settings.php
}

@test "non-Drupal installation" {
ddev config --project-name=${PROJNAME} --project-type=laravel --docroot=web --create-docroot
ddev config --project-name=${PROJNAME} --project-type=laravel --docroot=web
ddev start -y
cd ${TESTDIR}
ddev get ${DIR}
ddev add-on get ${DIR}
ddev restart
ddev redis-cli INFO | grep "^redis_version:6."
# Drupal configuration should not be present
[ ! -f web/sites/default/settings.ddev.redis.php ]
}

@test "Drupal 7 installation" {
ddev config --project-name=${PROJNAME} --project-type=drupal7 --docroot=web --create-docroot
ddev config --project-name=${PROJNAME} --project-type=drupal7 --docroot=web
ddev start -y
cd ${TESTDIR}
ddev get ${DIR}
ddev add-on get ${DIR}
ddev restart
ddev redis-cli INFO | grep "^redis_version:6."
# Drupal configuration should not be present
[ ! -f web/sites/default/settings.ddev.redis.php ]
}

@test "Drupal 9 installation without settings management" {
ddev config --project-name=${PROJNAME} --disable-settings-management --project-type=drupal9 --docroot=web --create-docroot
ddev config --project-name=${PROJNAME} --disable-settings-management --project-type=drupal --docroot=web
ddev start -y
cd ${TESTDIR}
ddev get ${DIR}
ddev add-on get ${DIR}
ddev restart
ddev redis-cli INFO | grep "^redis_version:6."
# Drupal configuration should not be present
Expand Down

0 comments on commit ce69968

Please sign in to comment.