86 lines
1.8 KiB
Markdown
86 lines
1.8 KiB
Markdown
# 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:
|
|
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
export TEST_DB_NAME=calypso
|
|
export TEST_DB_PASSWORD=calypso123
|
|
```
|
|
|
|
## Running Tests
|
|
|
|
### Run All Integration Tests
|
|
|
|
```bash
|
|
cd backend
|
|
go test ./tests/integration/... -v
|
|
```
|
|
|
|
### Run Specific Test
|
|
|
|
```bash
|
|
go test ./tests/integration/... -run TestHealthEndpoint -v
|
|
```
|
|
|
|
### Run with Coverage
|
|
|
|
```bash
|
|
go test -cover ./tests/integration/... -v
|
|
```
|
|
|
|
## Test Structure
|
|
|
|
- `setup.go` - Test database setup and helper functions
|
|
- `api_test.go` - API endpoint integration tests
|
|
|
|
## Test Coverage
|
|
|
|
### ✅ Implemented Tests
|
|
|
|
1. **TestHealthEndpoint** - Tests enhanced health check endpoint
|
|
2. **TestLoginEndpoint** - Tests user login with password verification
|
|
3. **TestLoginEndpoint_WrongPassword** - Tests wrong password rejection
|
|
4. **TestGetCurrentUser** - Tests authenticated user info retrieval
|
|
5. **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
|
|
|