aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.env.test5
-rw-r--r--.gitignore3
-rw-r--r--bolt.toml9
-rw-r--r--docker-compose.yml18
-rwxr-xr-xtask70
5 files changed, 104 insertions, 1 deletions
diff --git a/.env.test b/.env.test
new file mode 100644
index 0000000..d298ca7
--- /dev/null
+++ b/.env.test
@@ -0,0 +1,5 @@
+DB_NAME=test_db
+DB_HOST=test_db
+DB_PORT=5839
+DB_USERNAME=test_user
+DB_PASSWORD=testpassword
diff --git a/.gitignore b/.gitignore
index 65e4738..a0090b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-/bolt.toml
+# macOS
+.DS_Store
diff --git a/bolt.toml b/bolt.toml
new file mode 100644
index 0000000..0a40fa9
--- /dev/null
+++ b/bolt.toml
@@ -0,0 +1,9 @@
+migrations_dir = "migrations"
+
+[connection]
+host = "localhost"
+port = 5839
+user = "test_user"
+password = "testpassword"
+dbname = "test_db"
+driver = "postgres"
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..3479b02
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,18 @@
+version: '3.8'
+
+services:
+ postgres_db:
+ image: postgres:16.1-alpine3.19
+ container_name: postgres_db
+ ports:
+ - "${DB_PORT:?err}:5432"
+ environment:
+ - POSTGRES_DB=${DB_NAME:?err}
+ - POSTGRES_USER=${DB_USERNAME:?err}
+ - POSTGRES_PASSWORD=${DB_PASSWORD:?err}
+ volumes:
+ - postgres_db_volume:/var/lib/postgresql/data
+
+volumes:
+ postgres_db_volume:
+ name: postgres-db-volume
diff --git a/task b/task
new file mode 100755
index 0000000..18105b9
--- /dev/null
+++ b/task
@@ -0,0 +1,70 @@
+#!/bin/sh
+set -e
+
+print_help() {
+ echo "Usage: ./task <command>"
+ echo ""
+ echo "Commands:"
+ echo " help Print this help message or help information for a specific command"
+ echo " test Run the go test suite for the repo"
+ echo ""
+ echo "For more information on a specific command, use './task help <command>'"
+}
+
+run_tests() {
+ docker compose --env-file .env.test up -d
+
+ if [ "$1" = "-cov" ]; then
+ go test -cover ./...
+ else
+ go test ./...
+ fi
+
+ docker compose --env-file .env.test down --volumes
+}
+
+print_help_command() {
+ case "$1" in
+ help)
+ echo "Usage: ./task help <command>"
+ echo ""
+ echo "Commands:"
+ echo " help Print this help message"
+ echo " test Run the go test suite for the repo"
+ ;;
+ test)
+ echo "Usage: ./task test [-cov]"
+ echo ""
+ echo "Options:"
+ echo " -cov Generate a coverage report"
+ ;;
+ *)
+ echo "Invalid command. Use 'help' to see available commands."
+ ;;
+ esac
+}
+
+main() {
+ if [ $# -eq 0 ]; then
+ print_help
+ exit 1
+ fi
+
+ case "$1" in
+ help)
+ if [ $# -eq 1 ]; then
+ print_help
+ else
+ print_help_command "$2"
+ fi
+ ;;
+ test)
+ run_tests "$2"
+ ;;
+ *)
+ echo "Invalid command. Use 'help' to see available commands."
+ ;;
+ esac
+}
+
+main "$@"