diff --git a/docker-compose/setup-script/tests/configure/setup.sh b/docker-compose/setup-script/tests/configure/setup.sh new file mode 100644 index 0000000000..4763483ff7 --- /dev/null +++ b/docker-compose/setup-script/tests/configure/setup.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ -z "$NOCO_HOME" ]; then + NOCO_HOME="${HOME}/.nocodb" +fi + +if [ -d "$NOCO_HOME" ]; then + cd "$NOCO_HOME" || exit + docker compose down +fi + +cd /tmp || exit +rm -rf "$NOCO_HOME" + +../noco.sh <<< $'\n\nN\n' + +cd "$NOCO_HOME" || exit +docker compose down \ No newline at end of file diff --git a/docker-compose/setup-script/tests/configure/start.bats b/docker-compose/setup-script/tests/configure/start.bats new file mode 100644 index 0000000000..ea903e004f --- /dev/null +++ b/docker-compose/setup-script/tests/configure/start.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + +WORKING_DIR="$(pwd)" + +setup() { + cd "${WORKING_DIR}" || exit 1 + setup.sh +} + +teardown() { + cd "${WORKING_DIR}" || exit 1 + setup.sh +} + +@test "Check Redis, WatchTower and NocoDB are up" { + ../expects/configure/start.sh + + cd "${NOCO_HOME}" || exit 1 + + # Verify container is running + docker compose ps | grep -q 'redis' + docker compose ps | grep -q 'watchtower' + docker compose ps | grep -q 'nocodb' +} diff --git a/docker-compose/setup-script/tests/expects/configure/start.sh b/docker-compose/setup-script/tests/expects/configure/start.sh new file mode 100644 index 0000000000..7e52e1a7ae --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/start.sh @@ -0,0 +1,18 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "1\r" + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file diff --git a/docker-compose/setup-script/tests/install/default.bats b/docker-compose/setup-script/tests/install/default.bats index 1e3c5f4e82..a0e2c6cb78 100644 --- a/docker-compose/setup-script/tests/install/default.bats +++ b/docker-compose/setup-script/tests/install/default.bats @@ -7,12 +7,12 @@ WORKING_DIR="$(pwd)" setup() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } teardown() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } @test "Check Redis, WatchTower and NocoDB are up" { diff --git a/docker-compose/setup-script/tests/install/ip.bats b/docker-compose/setup-script/tests/install/ip.bats index 88f06890ca..41214a3c6d 100644 --- a/docker-compose/setup-script/tests/install/ip.bats +++ b/docker-compose/setup-script/tests/install/ip.bats @@ -7,12 +7,12 @@ WORKING_DIR="$(pwd)" setup() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } teardown() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } @test "Check Redis, WatchTower and NocoDB are up with custom ip" { diff --git a/docker-compose/setup-script/tests/install/redis.bats b/docker-compose/setup-script/tests/install/redis.bats index f81c81549b..c91e196bfb 100644 --- a/docker-compose/setup-script/tests/install/redis.bats +++ b/docker-compose/setup-script/tests/install/redis.bats @@ -7,12 +7,12 @@ WORKING_DIR="$(pwd)" setup() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } teardown() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } @test "Check Redis is enabled when specified" { diff --git a/docker-compose/setup-script/tests/install/scale.bats b/docker-compose/setup-script/tests/install/scale.bats index a4f1daea2d..c343bff930 100644 --- a/docker-compose/setup-script/tests/install/scale.bats +++ b/docker-compose/setup-script/tests/install/scale.bats @@ -7,12 +7,12 @@ WORKING_DIR="$(pwd)" setup() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } teardown() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } @test "Check if two instances of NoCoDB can be run" { diff --git a/docker-compose/setup-script/tests/setup.sh b/docker-compose/setup-script/tests/install/setup.sh similarity index 100% rename from docker-compose/setup-script/tests/setup.sh rename to docker-compose/setup-script/tests/install/setup.sh diff --git a/docker-compose/setup-script/tests/install/watchtower.bats b/docker-compose/setup-script/tests/install/watchtower.bats index 7449237b7e..3dd107ca7c 100644 --- a/docker-compose/setup-script/tests/install/watchtower.bats +++ b/docker-compose/setup-script/tests/install/watchtower.bats @@ -7,12 +7,12 @@ WORKING_DIR="$(pwd)" setup() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } teardown() { cd "${WORKING_DIR}" || exit 1 - ../setup.sh + setup.sh } @test "Check WatchTower is enabled when specified" {