A community based topic aggregation platform built on atproto

refactor: Centralize all config in .env.dev, remove run-tests.sh

**Simplified Configuration:**
- Test database credentials now in .env.dev (single source of truth)
- docker-compose.dev.yml uses env vars for test DB (POSTGRES_TEST_*)
- Makefile sources .env.dev for all test commands
- No need for separate .env.test file

**Removed:**
- run-tests.sh - Redundant, use `make test` instead

**Benefits:**
- All local dev config in one place (.env.dev)
- Less mental overhead (dev + test in same file)
- Consistent variable usage throughout stack
- Simpler developer onboarding

Usage:
- `make test` - Run all tests (handles DB automatically)
- All test config in .env.dev under "Test Database Configuration"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

+19 -7
.env.dev
···
# DO NOT commit secrets to version control in production!
# =============================================================================
-
# PostgreSQL Configuration (Shared Database)
+
# PostgreSQL Configuration (Development Database)
# =============================================================================
-
# Uses existing database from internal/db/local_dev_db_compose/
+
# Development database for Coves AppView (runs on port 5433)
POSTGRES_HOST=localhost
POSTGRES_PORT=5433
POSTGRES_DB=coves_dev
···
PDS_URL=http://localhost:3001
# =============================================================================
+
# Test Database Configuration
+
# =============================================================================
+
# Test database runs on port 5434 (separate from dev on 5433)
+
POSTGRES_TEST_DB=coves_test
+
POSTGRES_TEST_USER=test_user
+
POSTGRES_TEST_PASSWORD=test_password
+
POSTGRES_TEST_PORT=5434
+
+
# =============================================================================
# Development Settings
# =============================================================================
# Environment
···
# =============================================================================
# Notes
# =============================================================================
-
# - PDS port 3001 avoids conflict with your production PDS on :3000
-
# - AppView port 8081 avoids conflicts
-
# - PostgreSQL port 5433 matches your existing local dev database
-
# - All services connect to the shared PostgreSQL database
-
# - AppView subscribes directly to PDS firehose (no relay needed for local dev)
+
# All local development configuration in one file!
+
# - Dev PostgreSQL: port 5433
+
# - Test PostgreSQL: port 5434 (via --profile test)
+
# - PDS: port 3001 (avoids conflict with production on :3000)
+
# - AppView: port 8081
+
# - PDS is self-contained (SQLite + CAR files)
+
# - PostgreSQL is only for Coves AppView indexing
+
# - AppView subscribes directly to PDS firehose (no relay needed)
# - PDS firehose: ws://localhost:3001/xrpc/com.atproto.sync.subscribeRepos
+3 -3
Makefile
···
@echo "Waiting for test database to be ready..."
@sleep 3
@echo "$(GREEN)Running migrations on test database...$(RESET)"
-
@goose -dir internal/db/migrations postgres "postgresql://test_user:test_password@localhost:5434/coves_test?sslmode=disable" up || true
+
@. .env.dev && goose -dir internal/db/migrations postgres "postgresql://$$POSTGRES_TEST_USER:$$POSTGRES_TEST_PASSWORD@localhost:$$POSTGRES_TEST_PORT/$$POSTGRES_TEST_DB?sslmode=disable" up || true
@echo "$(GREEN)Running tests...$(RESET)"
-
@TEST_DATABASE_URL="postgresql://test_user:test_password@localhost:5434/coves_test?sslmode=disable" go test ./... -v
+
@. .env.dev && TEST_DATABASE_URL="postgresql://$$POSTGRES_TEST_USER:$$POSTGRES_TEST_PASSWORD@localhost:$$POSTGRES_TEST_PORT/$$POSTGRES_TEST_DB?sslmode=disable" go test ./... -v
@echo "$(GREEN)✓ Tests complete$(RESET)"
test-db-reset: ## Reset test database
···
@docker-compose -f docker-compose.dev.yml --env-file .env.dev --profile test up -d postgres-test
@echo "Waiting for PostgreSQL to be ready..."
@sleep 3
-
@goose -dir internal/db/migrations postgres "postgresql://test_user:test_password@localhost:5434/coves_test?sslmode=disable" up || true
+
@. .env.dev && goose -dir internal/db/migrations postgres "postgresql://$$POSTGRES_TEST_USER:$$POSTGRES_TEST_PASSWORD@localhost:$$POSTGRES_TEST_PORT/$$POSTGRES_TEST_DB?sslmode=disable" up || true
@echo "$(GREEN)✓ Test database reset$(RESET)"
test-db-stop: ## Stop test database
+5 -5
docker-compose.dev.yml
···
image: postgres:15
container_name: coves-test-postgres
ports:
-
- "5434:5432"
+
- "${POSTGRES_TEST_PORT:-5434}:5432"
environment:
-
POSTGRES_DB: coves_test
-
POSTGRES_USER: test_user
-
POSTGRES_PASSWORD: test_password
+
POSTGRES_DB: ${POSTGRES_TEST_DB:-coves_test}
+
POSTGRES_USER: ${POSTGRES_TEST_USER:-test_user}
+
POSTGRES_PASSWORD: ${POSTGRES_TEST_PASSWORD:-test_password}
volumes:
- postgres-test-data:/var/lib/postgresql/data
networks:
- coves-dev
healthcheck:
-
test: ["CMD-SHELL", "pg_isready -U test_user -d coves_test"]
+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_TEST_USER:-test_user} -d ${POSTGRES_TEST_DB:-coves_test}"]
interval: 5s
timeout: 5s
retries: 5
-50
run-tests.sh
···
-
#!/bin/bash
-
# Helper script to run tests with the test database
-
-
# Colors for output
-
GREEN='\033[0;32m'
-
RED='\033[0;31m'
-
NC='\033[0m' # No Color
-
-
echo "🧪 Coves Test Runner"
-
echo "==================="
-
echo ""
-
-
# Check if test database is running
-
if ! nc -z localhost 5434 2>/dev/null; then
-
echo -e "${RED}❌ Test database is not running${NC}"
-
echo ""
-
echo "Starting test database..."
-
cd internal/db/test_db_compose && ./start-test-db.sh
-
cd ../../..
-
echo ""
-
fi
-
-
# Load test environment
-
if [ -f .env.test ]; then
-
export $(cat .env.test | grep -v '^#' | xargs)
-
fi
-
-
# Run tests
-
echo "Running tests..."
-
echo ""
-
-
if [ $# -eq 0 ]; then
-
# No arguments, run all tests
-
go test -v ./...
-
else
-
# Pass arguments to go test
-
go test -v "$@"
-
fi
-
-
TEST_RESULT=$?
-
-
if [ $TEST_RESULT -eq 0 ]; then
-
echo ""
-
echo -e "${GREEN}✅ All tests passed!${NC}"
-
else
-
echo ""
-
echo -e "${RED}❌ Some tests failed${NC}"
-
fi
-
-
exit $TEST_RESULT