This documentation explains the testing architecture of the Database Backup Manager. We use a combination of Unit Tests, Integration Tests, and automated UI Seeding to ensure robustness across many database versions.
tests/
├── unit/ # Fast, isolated tests for utility logic (SemVer, Formatting, etc.)
├── integration/ # Heavy tests against REAL running database containers
│ ├── test-configs.ts # Source of Truth: Configuration for all test databases
│ └── *.test.ts # Test files (Connectivity, Backup, Restore)
└── README.md # This file
Fast checks for logic that doesn't need a database.
pnpm testRuns the full suite against 16+ real database containers.
- Prerequisite: Docker must be running.
- What happens: Auto-starts containers -> Runs Tests -> Shuts down.
pnpm run test:integrationWant to manually test backups in the browser against real databases?
pnpm run test:uiWhat this does:
- Starts all 16 database containers (MySQL 5-9, Postgres 12-17, Mongo 4-8).
- Seeds your local SQLite database with connections to all these containers (
Test MySQL 5.7,Test PG 16...). - Starts the Next.js dev server.
- You can open
http://localhost:3000and immediately start backing up/restoring without manual setup.
When you need to support or test a new database version (e.g., PostgreSQL 18 or Redis), follow these 3 Steps:
Define the service. Crucial: Ensure you assign a unique host port (e.g., if 54417 is taken, use 54418).
# In root/docker-compose.test.yml
postgres-18:
image: postgres:18-alpine # Use official image
container_name: dbm-test-pg-18
environment:
POSTGRES_DB: testdb
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpassword
ports:
- "54418:5432" # <--- UNIQUE PORT
healthcheck:
test: ["CMD-SHELL", "pg_isready -U testuser"]
interval: 5s
timeout: 5s
retries: 5This file is the Source of Truth. Both the integration tests AND the UI seeder read from here.
// tests/integration/test-configs.ts
export const testDatabases = [
// ... existing ...
{
name: 'Test PostgreSQL 18',
config: {
type: 'postgres',
host: 'localhost',
port: 54418, // Must match Docker Compose port
user: 'testuser',
password: 'testpassword',
database: 'testdb'
}
}
];Run the UI test command. The new database should appear in your Dashboard automatically.
pnpm run test:uiThis is the bridge between infrastructure (Docker) and Application (Next.js).
- Integration Tests iterate over this array to run
connectivity.test.tsagainst every defined DB. - Seeding Script (
scripts/seed-test-sources.ts) iterates over this array to INSERTAdapterConfigrows into your local SQLite DB.
We use a specific port range to avoid conflicts with your local services:
- MySQL:
33357(5.7) ->33390(9.0) - Postgres:
54412(v12) ->54417(v17) - Mongo:
27704(v4) ->27708(v8)
"Connection Refused" in Tests?
- Check if container is healthy:
docker ps - Did you use the correct mapped port? (e.g.,
54412not5432) - Is
setup-dev-macos.shor Docker Desktop actually running?
"Architecture Mismatch" (M1/M2 Mac)?
Some older images (MySQL 5.7) need platform: linux/amd64 in docker-compose.test.yml.