aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-08-18 15:10:05 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2024-08-18 15:10:05 -0400
commita7f3881536b2fb56b10b74af32172227633bd691 (patch)
tree396f61f962ddf3af13b7ea1f13fa7a2948254ea5 /tools
parentUpdate TOC in readme (diff)
downloadcli-a7f3881536b2fb56b10b74af32172227633bd691.zip
Add a couple helper scripts
Diffstat (limited to 'tools')
-rwxr-xr-xtools/db.sh31
-rwxr-xr-xtools/test.sh16
2 files changed, 47 insertions, 0 deletions
diff --git a/tools/db.sh b/tools/db.sh
new file mode 100755
index 0000000..27fe6d3
--- /dev/null
+++ b/tools/db.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# Start/Stop test databases.
+#
+# Subcommands:
+# start <database-name>: Start a particular database.
+# stop <database-name>: Stop a particular database.
+#
+# Usage:
+# $ ./tools/db.sh start <database-name>
+# $ ./tools/db.sh stop <database-name>
+BASE_DIR=`dirname $0`/..
+ALLOWED_DB=("postgresql" "mysql" "mssql" "sqlite3")
+
+if [[ ! " ${ALLOWED_DB[@]} " =~ " $2 " ]]; then
+ echo "Error: Invalid database type. Allowed types are: ${ALLOWED_DB[@]}"
+ exit 1
+fi
+
+case "$1" in
+ start)
+ env $(cat "$BASE_DIR/.env.$2" | xargs) docker compose -f "$BASE_DIR/docker-compose.$2.yml" up -d
+ ;;
+ stop)
+ env $(cat "$BASE_DIR/.env.$2" | xargs) docker compose -f "$BASE_DIR/docker-compose.$2.yml" down
+ ;;
+ *)
+ echo "Error: Invalid command. Use 'start' or 'stop'."
+ exit 1
+ ;;
+esac
diff --git a/tools/test.sh b/tools/test.sh
new file mode 100755
index 0000000..94826a9
--- /dev/null
+++ b/tools/test.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Run tests against a particular database.
+#
+# Usage:
+# $ ./tools/test.sh <database-name>
+BASE_DIR=`dirname $0`/..
+ALLOWED_DB=("postgresql" "mysql" "mssql" "sqlite3")
+
+if [[ ! " ${ALLOWED_DB[@]} " =~ " $1 " ]]; then
+ echo "Error: Invalid database type. Allowed types are: ${ALLOWED_DB[@]}"
+ exit 1
+fi
+
+env $(cat "$BASE_DIR/.env.$1" | xargs) go test -p 1 -tags "$1" -cover ./...
+