Manages PostgreSQL Docker containers for running database-dependent unit tests.
Install
mkdir -p .claude/skills/test-with-postgres && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5913" && unzip -o skill.zip -d .claude/skills/test-with-postgres && rm skill.zipInstalls to .claude/skills/test-with-postgres
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Run unit tests that require PostgreSQL. Use this skill when the user wants to run tests with PostgreSQL database backend. Automatically handles checking for and configuring a PostgreSQL Docker container.Key capabilities
- →Manage PostgreSQL Docker container lifecycle
- →Initialize test databases
- →Run Go tests with database connectivity
- →Cleanup test infrastructure after execution
How it works
It automates the startup, database creation, and teardown of a PostgreSQL Docker container to provide an isolated environment for unit tests.
Inputs & outputs
When to use test-with-postgres
- →Run Go tests requiring Postgres
- →Setup temporary Postgres DB for CI
- →Test database integration logic
About this skill
Run Unit Tests with PostgreSQL
You are helping run unit tests that require PostgreSQL.
Instructions
Starting PostgreSQL
PostgreSQL must be running before tests can execute. Use Docker to start a PostgreSQL instance:
# Check if postgres container is already running
docker ps --filter name=storj_unit_tests_postgres --format '{{.Names}}'
# If not running, start it:
docker run --rm -d -p 5433:5432 --name storj_unit_tests_postgres -e POSTGRES_PASSWORD=tmppass postgres:17
# Wait for postgres to be ready (retry until successful)
until docker exec storj_unit_tests_postgres psql -h localhost -U postgres -d postgres -c "select 1" > /dev/null 2>&1; do
echo "Waiting for postgres server..."
sleep 1
done
# Create test database
docker exec storj_unit_tests_postgres psql -h localhost -U postgres -c "create database teststorj;"
Alternatively, run testsuite/postgres-dev.sh which handles all setup automatically.
Running Tests
-
If test name is provided in arguments:
- Find the package containing the test using Grep
- Run the test with PostgreSQL configured
-
If only package path is provided:
- Run all tests in that package with PostgreSQL configured
-
Command format:
go test -v ./package/path -run TestName -postgres-test-db 'postgres://postgres:tmppass@localhost:5433/teststorj?sslmode=disable'
-
Report test results:
- Show whether tests passed or failed
- List all subtests that ran
- If tests failed, offer to help investigate the failures
-
Stop the Docker container after tests complete:
docker rm -f storj_unit_tests_postgres
Common test paths
Some common test paths in the Storj codebase:
./satellite/metabase- Metabase tests./satellite/metainfo- Metainfo API tests./satellite/satellitedb- Database tests
Example Usage
# Run a specific test
go test -v ./satellite/metainfo -run TestEndpoint_Object_No_StorageNodes -postgres-test-db 'postgres://postgres:tmppass@localhost:5433/teststorj?sslmode=disable'
# Run all tests in a package
go test -v ./satellite/metabase -postgres-test-db 'postgres://postgres:tmppass@localhost:5433/teststorj?sslmode=disable'
# Run tests with timeout
go test -v -timeout 10m ./satellite/metabase -run TestLoop -postgres-test-db 'postgres://postgres:tmppass@localhost:5433/teststorj?sslmode=disable'
Cleanup
To stop the PostgreSQL container when done:
docker rm -f storj_unit_tests_postgres
Notes
- The container uses port 5433 to avoid conflicts with any local PostgreSQL installation on the default port 5432
- Tests automatically create isolated test databases for each test run
- Use
STORJ_TEST_POSTGRES='omit'to skip PostgreSQL tests
When not to use it
- →When tests do not require a PostgreSQL backend
Prerequisites
Limitations
- →Uses port 5433 to avoid conflicts
How it compares
It handles the entire database lifecycle automatically, whereas manual testing requires manual container management.
Compared to similar skills
test-with-postgres side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| test-with-postgres (this skill) | 1 | 2mo | Review | Intermediate |
| supabase-local-dev-loop | 0 | 26d | Caution | Beginner |
| generating-database-seed-data | 10 | 26d | Review | Intermediate |
| managing-database-tests | 1 | 26d | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by storj
View all by storj →You might also like
supabase-local-dev-loop
jeremylongshore
Configure Supabase local development with hot reload and testing. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with Supabase. Trigger with phrases like "supabase dev setup", "supabase local development", "supabase dev environment", "develop with supabase".
generating-database-seed-data
jeremylongshore
Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.
managing-database-tests
jeremylongshore
Test database testing including fixtures, transactions, and rollback management. Use when performing specialized testing. Trigger with phrases like "test the database", "run database tests", or "validate data integrity".
sql-optimization-patterns
wshobson
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.
drizzle-orm
EpicenterHQ
Drizzle ORM patterns for type branding and custom types. Use when working with Drizzle column definitions, branded types, or custom type conversions.
postgres-patterns
affaan-m
PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.