summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-07-24 13:14:13 +0100
committerLibravatar GitHub <noreply@github.com>2023-07-24 13:14:13 +0100
commit9eff0d46e49b947dc2642207ee49ed657eb6b565 (patch)
tree62994afff170737d83f1ed911e385504a0ad16cd /test
parent[chore]: Bump github.com/microcosm-cc/bluemonday from 1.0.24 to 1.0.25 (#2021) (diff)
downloadgotosocial-9eff0d46e49b947dc2642207ee49ed657eb6b565.tar.xz
[feature/performance] support uncaching remote emoji + scheduled cleanup functions (#1987)
Diffstat (limited to 'test')
-rwxr-xr-xtest/run-postgres.sh37
-rwxr-xr-xtest/run-sqlite.sh7
2 files changed, 44 insertions, 0 deletions
diff --git a/test/run-postgres.sh b/test/run-postgres.sh
new file mode 100755
index 000000000..54e4970ed
--- /dev/null
+++ b/test/run-postgres.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+set -e
+
+DB_NAME='postgres'
+DB_USER='postgres'
+DB_PASS='postgres'
+DB_PORT=5432
+
+# Start postgres container
+CID=$(docker run --detach \
+ --env "POSTGRES_DB=${DB_NAME}" \
+ --env "POSTGRES_USER=${DB_USER}" \
+ --env "POSTGRES_PASSWORD=${DB_PASS}" \
+ --env "POSTGRES_HOST_AUTH_METHOD=trust" \
+ --env "PGHOST=0.0.0.0" \
+ --env "PGPORT=${DB_PORT}" \
+ 'postgres:latest')
+
+# On exit kill the container
+trap "docker kill ${CID}" exit
+
+sleep 5
+#docker exec "$CID" psql --user "$DB_USER" --password "$DB_PASS" -c "CREATE DATABASE \"${DB_NAME}\" WITH LOCALE \"C.UTF-8\" TEMPLATE \"template0\";"
+docker exec "$CID" psql --user "$DB_USER" --password "$DB_PASS" -c "GRANT ALL PRIVILEGES ON DATABASE \"${DB_NAME}\" TO \"${DB_USER}\";"
+
+# Get running container IP
+IP=$(docker container inspect "${CID}" \
+ --format '{{ .NetworkSettings.IPAddress }}')
+
+GTS_DB_TYPE=postgres \
+GTS_DB_ADDRESS=${IP} \
+GTS_DB_PORT=${DB_PORT} \
+GTS_DB_USER=${DB_USER} \
+GTS_DB_PASSWORD=${DB_PASS} \
+GTS_DB_DATABASE=${DB_NAME} \
+go test ./... -p 1 ${@} \ No newline at end of file
diff --git a/test/run-sqlite.sh b/test/run-sqlite.sh
new file mode 100755
index 000000000..fb5502432
--- /dev/null
+++ b/test/run-sqlite.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+GTS_DB_TYPE=sqlite \
+GTS_DB_ADDRESS=':memory:' \
+go test ./... ${@} \ No newline at end of file