From 635ab81d01dfe54c07fb485e8c8e061f2871a5b8 Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Thu, 2 May 2024 12:10:07 +0000 Subject: [PATCH] test: test for default case and for custom ip --- .../tests/expects/install/default.sh | 19 +++++++++++ .../setup-script/tests/expects/install/ip.sh | 20 ++++++++++++ .../setup-script/tests/install/default.bats | 32 +++++++++++++++++++ .../setup-script/tests/install/ip.bats | 32 +++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100755 docker-compose/setup-script/tests/expects/install/default.sh create mode 100755 docker-compose/setup-script/tests/expects/install/ip.sh create mode 100644 docker-compose/setup-script/tests/install/default.bats create mode 100644 docker-compose/setup-script/tests/install/ip.bats 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..9dc978704e --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/default.sh @@ -0,0 +1,19 @@ +#!/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 "\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..ab767dfcb6 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/ip.sh @@ -0,0 +1,20 @@ +#!/usr/bin/expect -f +# shellcheck shell=bash + +# 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 "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/install/default.bats b/docker-compose/setup-script/tests/install/default.bats new file mode 100644 index 0000000000..1e3c5f4e82 --- /dev/null +++ b/docker-compose/setup-script/tests/install/default.bats @@ -0,0 +1,32 @@ +#!/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/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 100644 index 0000000000..88f06890ca --- /dev/null +++ b/docker-compose/setup-script/tests/install/ip.bats @@ -0,0 +1,32 @@ +#!/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 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' +}