A community based topic aggregation platform built on atproto
1# Test Database Setup 2 3This directory contains the Docker Compose configuration for the Coves test database. 4 5## Overview 6 7The test database is a PostgreSQL instance specifically for running automated tests. It's completely isolated from development and production databases. 8 9### Configuration 10 11- **Port**: 5434 (different from dev: 5433, prod: 5432) 12- **Database**: coves_test 13- **User**: test_user 14- **Password**: test_password 15- **Data Volume**: ~/Code/Coves/test_db_data 16 17## Usage 18 19### Starting the Test Database 20 21```bash 22cd internal/db/test_db_compose 23./start-test-db.sh 24``` 25 26This will: 271. Start the PostgreSQL container 282. Wait for it to be ready 293. Display the connection string 30 31### Running Tests 32 33Once the database is running, you can run tests with: 34 35```bash 36TEST_DATABASE_URL=postgres://test_user:test_password@localhost:5434/coves_test?sslmode=disable go test -v ./... 37``` 38 39Or set the environment variable: 40 41```bash 42export TEST_DATABASE_URL=postgres://test_user:test_password@localhost:5434/coves_test?sslmode=disable 43go test -v ./... 44``` 45 46### Stopping the Test Database 47 48```bash 49./stop-test-db.sh 50``` 51 52### Resetting Test Data 53 54To completely reset the test database (removes all data): 55 56```bash 57./reset-test-db.sh 58``` 59 60## Test Isolation 61 62The test database is isolated from other environments: 63 64| Environment | Port | Database Name | User | 65|------------|------|--------------|------| 66| Test | 5434 | coves_test | test_user | 67| Development | 5433 | coves_dev | dev_user | 68| Production | 5432 | coves | (varies) | 69 70## What Gets Tested 71 72When tests run against this database, they will: 73 741. Run all migrations from `internal/db/migrations/` 752. Create Indigo carstore tables (via GORM auto-migration) 763. Test the full integration including: 77 - Repository CRUD operations 78 - CAR file metadata storage 79 - User DID to UID mapping 80 - Carstore operations 81 82## CI/CD Integration 83 84For CI/CD pipelines, you can use the same Docker Compose setup or connect to a dedicated test database instance.