diff --git a/.github/workflows/bats-test.yml b/.github/workflows/bats-test.yml new file mode 100644 index 0000000000..49e26b6e6b --- /dev/null +++ b/.github/workflows/bats-test.yml @@ -0,0 +1,55 @@ +name: Run BATS Tests + +on: + push: + paths: + - 'docker-compose/setup-script/noco.sh' + workflow_dispatch: + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install jq + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Prepare matrix for test files + id: set-matrix + run: | + BATS_FILES=$(find docker-compose/setup-script/tests -name '*.bats') + MATRIX_JSON=$(echo $BATS_FILES | jq -Rsc 'split("\n") | map(select(. != ""))') + echo "matrix=$MATRIX_JSON" >> $GITHUB_ENV + + test: + needs: prepare + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + test: ${{fromJson(env.matrix)}} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install BATS + run: | + sudo apt-get update + sudo apt-get install -y bats expect + + - name: Get working directory + run: | + WORKING_DIR="$(pwd)/docker-compose/setup-script/tests" + echo "WORKING_DIR=$WORKING_DIR" >> $GITHUB_ENV + + - name: Run BATS test + run: bats ${{ matrix.test }} + env: + WORKING_DIR: ${{ env.WORKING_DIR }} + SKIP_TARE_DOWN: true diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 3ad867d891..2c5c809d10 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -376,7 +376,7 @@ REQUIRED_PORTS=(80 443) echo "** Performing nocodb system check and setup. This step may require sudo permissions" -# pre install wget if not found +# pre-install wget if not found if ! command_exists wget; then echo "wget is not installed. Setting up for installation..." install_package wget @@ -399,7 +399,7 @@ done # f. Port mapping check echo " | Checking port accessibility..." for port in "${REQUIRED_PORTS[@]}"; do - if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null; then + if lsof -Pi :"$port" -sTCP:LISTEN -t >/dev/null; then echo " | WARNING: Port $port is in use. Please make sure it is free." >&2 else echo " | Port $port is free." @@ -459,7 +459,7 @@ fi if [ -n "$EDITION" ] && { [ "$EDITION" = "EE" ] || [ "$EDITION" = "ee" ]; }; then echo "Enter the NocoDB license key: " - read LICENSE_KEY + read -r LICENSE_KEY if [ -z "$LICENSE_KEY" ]; then echo "License key is required for Enterprise Edition installation" exit 1 diff --git a/docker-compose/setup-script/tests/configure/monitor.bats b/docker-compose/setup-script/tests/configure/monitor.bats new file mode 100755 index 0000000000..ae20a2d85f --- /dev/null +++ b/docker-compose/setup-script/tests/configure/monitor.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/configure" || exit 1 + ./setup.sh "setup" +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Properly runs monitor script" { + ../expects/configure/restart.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/configure/restart.bats b/docker-compose/setup-script/tests/configure/restart.bats new file mode 100755 index 0000000000..2f92868882 --- /dev/null +++ b/docker-compose/setup-script/tests/configure/restart.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/configure" || exit 1 + ./setup.sh "setup" +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check all containers are restarted" { + ../expects/configure/restart.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/configure/scale.bats b/docker-compose/setup-script/tests/configure/scale.bats new file mode 100755 index 0000000000..b2bbadd45d --- /dev/null +++ b/docker-compose/setup-script/tests/configure/scale.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/configure" || exit 1 + ./setup.sh "setup" +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check NocoDB is scaled to 3 instances" { + nproc() { + echo 4 + } + + ../expects/configure/scale.sh + + cd "${NOCO_HOME}" || exit 1 + + result=$(docker compose ps | grep -c "nocodb/nocodb") + [ "${result}" -eq 3 ] +} diff --git a/docker-compose/setup-script/tests/configure/setup.sh b/docker-compose/setup-script/tests/configure/setup.sh new file mode 100755 index 0000000000..3eee2485b5 --- /dev/null +++ b/docker-compose/setup-script/tests/configure/setup.sh @@ -0,0 +1,17 @@ +#!/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 "$WORKING_DIR" || exit +rm -rf "$NOCO_HOME" + +if [ "$1" = "setup" ]; then + ../noco.sh <<< $'\n\nN\n' +fi diff --git a/docker-compose/setup-script/tests/configure/start.bats b/docker-compose/setup-script/tests/configure/start.bats new file mode 100755 index 0000000000..b438e516eb --- /dev/null +++ b/docker-compose/setup-script/tests/configure/start.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/configure" || exit 1 + ./setup.sh "setup" +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check all containers 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/configure/stop.bats b/docker-compose/setup-script/tests/configure/stop.bats new file mode 100755 index 0000000000..47f202dfa4 --- /dev/null +++ b/docker-compose/setup-script/tests/configure/stop.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/configure" || exit 1 + ./setup.sh setup +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check all containers are down" { + ../expects/configure/stop.sh + + cd "${NOCO_HOME}" || exit 1 + + # Verify container is not running + count=$(docker compose ps -q | wc -l) + [ "$count" -eq 0 ] +} diff --git a/docker-compose/setup-script/tests/configure/upgrade.bats b/docker-compose/setup-script/tests/configure/upgrade.bats new file mode 100755 index 0000000000..b0e9f6275a --- /dev/null +++ b/docker-compose/setup-script/tests/configure/upgrade.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/configure" || exit 1 + ./setup.sh "setup" +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check all containers are upgraded" { + ../expects/configure/upgrade.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/monitor.sh b/docker-compose/setup-script/tests/expects/configure/monitor.sh new file mode 100755 index 0000000000..ba7479de81 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/monitor.sh @@ -0,0 +1,22 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "7\r" + +send \x03 + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file diff --git a/docker-compose/setup-script/tests/expects/configure/restart.sh b/docker-compose/setup-script/tests/expects/configure/restart.sh new file mode 100755 index 0000000000..7abddf658c --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/restart.sh @@ -0,0 +1,20 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "4\r" + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file diff --git a/docker-compose/setup-script/tests/expects/configure/scale.sh b/docker-compose/setup-script/tests/expects/configure/scale.sh new file mode 100755 index 0000000000..2f3196ade7 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/scale.sh @@ -0,0 +1,23 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "6\r" + +expect "How many instances of NocoDB do you want to run*" +send "3\r" + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file 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 100755 index 0000000000..ed8796c965 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/start.sh @@ -0,0 +1,20 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +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/expects/configure/stop.sh b/docker-compose/setup-script/tests/expects/configure/stop.sh new file mode 100755 index 0000000000..78ef89592a --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/stop.sh @@ -0,0 +1,20 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "2\r" + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file diff --git a/docker-compose/setup-script/tests/expects/configure/upgrade.sh b/docker-compose/setup-script/tests/expects/configure/upgrade.sh new file mode 100755 index 0000000000..c03edb366d --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/upgrade.sh @@ -0,0 +1,20 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "5\r" + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file diff --git a/docker-compose/setup-script/tests/expects/install/default.sh b/docker-compose/setup-script/tests/expects/install/default.sh new file mode 100755 index 0000000000..fa4fb58d3a --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/default.sh @@ -0,0 +1,21 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +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 "\r" + +expect "Do you want to start the management menu*" +send "N\r" + +expect eof diff --git a/docker-compose/setup-script/tests/expects/install/ip.sh b/docker-compose/setup-script/tests/expects/install/ip.sh new file mode 100755 index 0000000000..957a677efe --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/ip.sh @@ -0,0 +1,22 @@ +#!/usr/bin/expect -f +# shellcheck shell=bash + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +spawn bash ../../noco.sh + +# Respond to script prompts +expect "Enter the IP address or domain name for the NocoDB instance (default: localhost):" +send "192.168.1.10\r" + +expect "Show Advanced Options*" +send "\r" + +expect "Do you want to start the management menu*" +send "N\r" + +expect eof diff --git a/docker-compose/setup-script/tests/expects/install/redis.sh b/docker-compose/setup-script/tests/expects/install/redis.sh new file mode 100755 index 0000000000..c3420a3007 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/redis.sh @@ -0,0 +1,33 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +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/expects/install/scale.sh b/docker-compose/setup-script/tests/expects/install/scale.sh new file mode 100755 index 0000000000..584fb87cf7 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/scale.sh @@ -0,0 +1,33 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +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 "2\r" + +expect "Do you want to start the management menu*" +send "N\r" + +expect eof diff --git a/docker-compose/setup-script/tests/expects/install/ssl.sh b/docker-compose/setup-script/tests/expects/install/ssl.sh new file mode 100755 index 0000000000..229896067d --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/ssl.sh @@ -0,0 +1,38 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +set random_number [lindex $argv 0] + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +spawn bash ../../noco.sh + +# Respond to script prompts +expect "Enter the IP address or domain name for the NocoDB instance (default: localhost):" +send "${random_number}.ssl.nocodb.dev\r" + +expect "Show Advanced Options*" +send "y\r" + +expect "Do you want to configure SSL*" +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/expects/install/watchtower.sh b/docker-compose/setup-script/tests/expects/install/watchtower.sh new file mode 100755 index 0000000000..eeb4f6e493 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/watchtower.sh @@ -0,0 +1,33 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +set env(PATH) "$env(WORKING_DIR)/mocks:$env(PATH)" + +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 "\r" + +expect "Do you want to enabled Watchtower for automatic updates*" +send "Y\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/install/default.bats b/docker-compose/setup-script/tests/install/default.bats new file mode 100755 index 0000000000..ef6e758d23 --- /dev/null +++ b/docker-compose/setup-script/tests/install/default.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check installation with all default options" { + ../expects/install/default.sh + + cd "${NOCO_HOME}" + + # Check Docker Compose file to verify configuration + grep -q 'redis' docker-compose.yml + grep -q 'watchtower' docker-compose.yml + grep -q 'nocodb' docker-compose.yml + + # 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/install/ip.bats b/docker-compose/setup-script/tests/install/ip.bats new file mode 100755 index 0000000000..e3fbc1b547 --- /dev/null +++ b/docker-compose/setup-script/tests/install/ip.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check installation with custom ip" { + ../expects/install/ip.sh + + cd "${NOCO_HOME}" + + # Check Docker Compose file to verify configuration + grep -q 'redis' docker-compose.yml + grep -q 'watchtower' docker-compose.yml + grep -q 'nocodb' docker-compose.yml + + # 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/install/redis.bats b/docker-compose/setup-script/tests/install/redis.bats new file mode 100755 index 0000000000..fba5db9add --- /dev/null +++ b/docker-compose/setup-script/tests/install/redis.bats @@ -0,0 +1,32 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check Redis is enabled when specified" { + ../expects/install/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/install/scale.bats b/docker-compose/setup-script/tests/install/scale.bats new file mode 100755 index 0000000000..73d3e325e5 --- /dev/null +++ b/docker-compose/setup-script/tests/install/scale.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + + + +setup() { + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check if two instances of NoCoDB can be run" { + ../expects/install/scale.sh + + cd "${NOCO_HOME}" + + # Get scale from docker compose ps + scale=$(docker compose ps | grep -c "nocodb/nocodb") + [ "$scale" -eq 2 ] +} diff --git a/docker-compose/setup-script/tests/install/setup.sh b/docker-compose/setup-script/tests/install/setup.sh new file mode 100755 index 0000000000..2397e20809 --- /dev/null +++ b/docker-compose/setup-script/tests/install/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" || exit + docker compose down +fi + +rm -rf "$NOCO_HOME" diff --git a/docker-compose/setup-script/tests/install/ssl.bats b/docker-compose/setup-script/tests/install/ssl.bats new file mode 100644 index 0000000000..705120b7af --- /dev/null +++ b/docker-compose/setup-script/tests/install/ssl.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats + + + +RANDOM_NUMBER=$RANDOM + +setup() { + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Should create SSL certificates" { + if [ -z "$TEST_SSL" ] + then + skip "Skipping SSL tests" + fi + + ../expects/install/ssl.sh "$RANDOM_NUMBER" + + curl -ksS --head "https://${RANDOM_NUMBER}.ssl.nocodb.dev" > /dev/null +} diff --git a/docker-compose/setup-script/tests/install/watchtower.bats b/docker-compose/setup-script/tests/install/watchtower.bats new file mode 100755 index 0000000000..32c988809c --- /dev/null +++ b/docker-compose/setup-script/tests/install/watchtower.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + +setup() { + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +teardown() { + if [ -n "$SKIP_TEARDOWN" ]; then + return + fi + + cd "${WORKING_DIR}/install" || exit 1 + ./setup.sh +} + +@test "Check WatchTower is enabled when specified" { + ../expects/install/watchtower.sh + + cd "${NOCO_HOME}" + + # Check Docker Compose file to verify WatchTower configuration + grep -q 'watchtower' docker-compose.yml + + # Verify WatchTower container is running + docker compose ps | grep -q 'watchtower' +} diff --git a/docker-compose/setup-script/tests/mocks/clear b/docker-compose/setup-script/tests/mocks/clear new file mode 100755 index 0000000000..e08f792e8f --- /dev/null +++ b/docker-compose/setup-script/tests/mocks/clear @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "--- Clear Mock ---" \ No newline at end of file diff --git a/docker-compose/setup-script/tests/mocks/nproc b/docker-compose/setup-script/tests/mocks/nproc new file mode 100755 index 0000000000..1d83c4a9b0 --- /dev/null +++ b/docker-compose/setup-script/tests/mocks/nproc @@ -0,0 +1,3 @@ +#!/bin/bash + +echo 4 \ No newline at end of file