test(api): add API test on contacts

next will be to add CI on it
This commit is contained in:
Edouard Vanbelle
2026-05-11 00:50:39 +02:00
parent 03aac93db3
commit 8ab537797a
14 changed files with 530 additions and 55 deletions
+16
View File
@@ -0,0 +1,16 @@
services:
postgres-test:
image: postgres:18.2-alpine3.23
environment:
POSTGRES_USER: oxicloud_test
POSTGRES_PASSWORD: oxicloud_test
POSTGRES_DB: oxicloud_test
ports:
- "5433:5432"
tmpfs:
- /var/lib/postgresql # in-memory: always blank on start (pg18+ uses /var/lib/postgresql/18/data)
healthcheck:
test: ["CMD-SHELL", "pg_isready -U oxicloud_test"]
interval: 2s
timeout: 5s
retries: 10
+18
View File
@@ -0,0 +1,18 @@
# Shared test-server environment variables.
# Sourced by tests/api/run.sh (shell) and read by tests/e2e/playwright.config.ts (Node).
# Do NOT include OXICLOUD_SERVER_PORT or OXICLOUD_STORAGE_PATH here —
# each test suite sets those to avoid port/directory conflicts.
DATABASE_URL=postgres://oxicloud_test:oxicloud_test@localhost:5433/oxicloud_test
OXICLOUD_DB_CONNECTION_STRING=postgres://oxicloud_test:oxicloud_test@localhost:5433/oxicloud_test
OXICLOUD_STATIC_PATH=./static
OXICLOUD_JWT_SECRET=test-secret-do-not-use-in-prod-minimum-32-chars
OXICLOUD_ENABLE_AUTH=true
OXICLOUD_ENABLE_TRASH=true
OXICLOUD_ENABLE_SEARCH=true
OXICLOUD_ENABLE_FILE_SHARING=true
OXICLOUD_ENABLE_MUSIC=true
OXICLOUD_EXPOSE_SYSTEM_USERS=true
OXICLOUD_WOPI_ENABLED=false
OXICLOUD_OIDC_ENABLED=false
RUST_LOG=info
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
COMPOSE_FILE="$(dirname "$0")/docker-compose.test.yml"
wait_for_port() {
local host="$1" port="$2" timeout="${3:-30}"
local deadline=$(( $(date +%s) + timeout ))
until nc -z "$host" "$port" 2>/dev/null; do
[[ $(date +%s) -ge $deadline ]] && echo "Timeout waiting for $host:$port" >&2 && exit 1
sleep 0.5
done
}
echo "[setup] Starting test postgres..."
docker compose -f "$COMPOSE_FILE" down -v 2>/dev/null || true
docker compose -f "$COMPOSE_FILE" up -d
echo "[setup] Waiting for postgres on port 5433..."
wait_for_port 127.0.0.1 5433
echo "[setup] Postgres is ready."
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
COMPOSE_FILE="$(dirname "$0")/docker-compose.test.yml"
echo "[teardown] Stopping test postgres..."
docker compose -f "$COMPOSE_FILE" down -v