Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Require an explicit docker|host target in the test runner

Manav Rathi476665b150e1
diff --git a/.github/workflows/server-test.yml b/.github/workflows/server-test.yml
index 330d69edc9..e5c6473760 100644
--- a/.github/workflows/server-test.yml
+++ b/.github/workflows/server-test.yml
@@ -32,4 +32,4 @@ jobs:
cache: true
- name: Run server tests
- run: ./scripts/test-with-postgres.sh
+ run: ./scripts/test-with-postgres.sh docker
diff --git a/server/RUNNING.md b/server/RUNNING.md
index c81e5bf59d..89d2900753 100644
--- a/server/RUNNING.md
+++ b/server/RUNNING.md
@@ -232,11 +232,15 @@ For quick local iteration without Postgres-backed tests, run `go test ./...` or
To run the full `server/` Go test suite, including Postgres-backed tests, use:
```sh
-./scripts/test-with-postgres.sh
-./scripts/test-with-postgres.sh -v
+./scripts/test-with-postgres.sh docker
+./scripts/test-with-postgres.sh host -v
```
-The script creates a temporary `ente_test_*` database, runs the tests, and drops the database when it exits. By default it starts a disposable Docker Postgres if Docker is available. To use an existing local Postgres instead, set `ENTE_TEST_POSTGRES=local`.
+- `docker` runs the tests against a throwaway Docker Postgres
+- `host` runs them against the existing Postgres on your machine
+- any other args after `<docker|host>` are forwarded to the `go test` invocation
+
+The script creates a temporary `ente_test_*` database on the selected Postgres instance, runs the tests, and drops the database when it exits.
## Configuration
diff --git a/server/scripts/test-with-postgres.sh b/server/scripts/test-with-postgres.sh
index 9b14d2e556..f5a975f817 100755
--- a/server/scripts/test-with-postgres.sh
+++ b/server/scripts/test-with-postgres.sh
@@ -1,20 +1,23 @@
#!/bin/sh
-# Runs the server test suite against a disposable Postgres database.
-# Uses a throwaway Docker Postgres by default; ENTE_TEST_POSTGRES=local
-# uses the existing local Postgres instead. See RUNNING.md.
+# Runs the server test suite against a disposable Postgres database on either:
+#
+# * docker - creates a temporary Postgres container in Docker;
+#
+# * host - uses the existing Postgres on localhost.
+#
+# See RUNNING.md for more details.
set -eu
cd "$(dirname "$0")/.."
test_db="ente_test_$(date +%Y%m%d%H%M%S)_$$"
-mode="${ENTE_TEST_POSTGRES:-auto}"
+mode="${1:-}"
case "$mode" in
- auto) if docker info >/dev/null 2>&1; then mode=docker; else mode=local; fi ;;
- docker | local) ;;
- *) echo "Unsupported ENTE_TEST_POSTGRES=$mode. Use auto, docker, or local." >&2; exit 1 ;;
+ docker | host) shift ;;
+ *) echo "usage: $0 <docker|host> [go test flags]" >&2; exit 1 ;;
esac
if [ "$mode" = docker ]; then