Integration Tests
This directory contains integration tests for the Calypso API.
Setup
1. Create Test Database (Optional)
For isolated testing, create a separate test database:
sudo -u postgres createdb calypso_test
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE calypso_test TO calypso;"
2. Environment Variables
Set test database configuration:
export TEST_DB_HOST=localhost
export TEST_DB_PORT=5432
export TEST_DB_USER=calypso
export TEST_DB_PASSWORD=calypso123
export TEST_DB_NAME=calypso_test # or use existing 'calypso' database
Or use the existing database:
export TEST_DB_NAME=calypso
export TEST_DB_PASSWORD=calypso123
Running Tests
Run All Integration Tests
cd backend
go test ./tests/integration/... -v
Run Specific Test
go test ./tests/integration/... -run TestHealthEndpoint -v
Run with Coverage
go test -cover ./tests/integration/... -v
Test Structure
setup.go- Test database setup and helper functionsapi_test.go- API endpoint integration tests
Test Coverage
✅ Implemented Tests
- TestHealthEndpoint - Tests enhanced health check endpoint
- TestLoginEndpoint - Tests user login with password verification
- TestLoginEndpoint_WrongPassword - Tests wrong password rejection
- TestGetCurrentUser - Tests authenticated user info retrieval
- TestListAlerts - Tests monitoring alerts endpoint
⏳ Future Tests
- Storage endpoints
- SCST endpoints
- VTL endpoints
- Task management
- IAM endpoints
Notes
- Tests use the actual database (test or production)
- Tests clean up data after each test run
- Tests create test users with proper password hashing
- Tests verify authentication and authorization