diff --git a/docker-compose/setup-script/tests/expects/redis.sh b/docker-compose/setup-script/tests/expects/redis.sh new file mode 100755 index 0000000000..652f990068 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/redis.sh @@ -0,0 +1,31 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +spawn bash ../noco.sh + +# Respond to script prompts +expect "Enter the IP address or domain name for the NocoDB instance (default: localhost):" +send "\r" + +expect "Show Advanced Options*" +send "Y\r" + +expect "Choose Community or Enterprise Edition*" +send "\r" + +expect "Do you want to enabled Redis for caching*" +send "Y\r" + +expect "Do you want to enabled Watchtower for automatic updates*" +send "\r" + +expect "How many instances of NocoDB do you want to run*" +send "\r" + +expect "Do you want to start the management menu*" +send "N\r" + +expect eof diff --git a/docker-compose/setup-script/tests/redis.bats b/docker-compose/setup-script/tests/redis.bats new file mode 100644 index 0000000000..6984d4e96a --- /dev/null +++ b/docker-compose/setup-script/tests/redis.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + +WORKING_DIR="$(pwd)" + +setup() { + cd "${WORKING_DIR}" + ./setup.sh +} + +teardown() { + cd "${WORKING_DIR}" + ./setup.sh +} + +@test "Check Redis is enabled when specified" { + ./expects/redis.sh + + cd "${NOCO_HOME}" + + # Check Docker Compose file to verify Redis configuration + grep -q 'redis' docker-compose.yml + + # Verify Redis container is running + docker compose ps | grep -q 'redis' +} diff --git a/docker-compose/setup-script/tests/setup.sh b/docker-compose/setup-script/tests/setup.sh new file mode 100755 index 0000000000..e3a24ce010 --- /dev/null +++ b/docker-compose/setup-script/tests/setup.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ -z "$NOCO_HOME" ]; then + NOCO_HOME="${HOME}/.nocodb" +fi + +if [ -d "$NOCO_HOME" ]; then + cd $NOCO_HOME + docker compose down +fi + +rm -rf $NOCO_HOME