# Quick Start Testing Guide

This is a condensed guide to quickly test the Calypso API.

## 1. Setup (One-time)

```bash
# Install requirements
sudo ./scripts/install-requirements.sh

# Setup database
sudo -u postgres createdb calypso
sudo -u postgres createuser calypso
sudo -u postgres psql -c "ALTER USER calypso WITH PASSWORD 'calypso123';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE calypso TO calypso;"

# Create test user
./scripts/setup-test-user.sh

# Set environment variables
export CALYPSO_DB_PASSWORD="calypso123"
export CALYPSO_JWT_SECRET="test-jwt-secret-key-minimum-32-characters-long"
```

## 2. Start the API

```bash
cd backend
go mod download
go run ./cmd/calypso-api -config config.yaml.example
```

## 3. Run Automated Tests

In another terminal:

```bash
./scripts/test-api.sh
```

## 4. Manual Testing

### Get a token:
```bash
TOKEN=$(curl -s -X POST http://localhost:8080/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123"}' | jq -r '.token')
```

### Test endpoints:
```bash
# Health
curl http://localhost:8080/api/v1/health

# Current user
curl http://localhost:8080/api/v1/auth/me \
  -H "Authorization: Bearer $TOKEN"

# List disks
curl http://localhost:8080/api/v1/storage/disks \
  -H "Authorization: Bearer $TOKEN"

# List services
curl http://localhost:8080/api/v1/system/services \
  -H "Authorization: Bearer $TOKEN"
```

## Troubleshooting

- **Database connection fails**: Check PostgreSQL is running: `sudo systemctl status postgresql`
- **401 Unauthorized**: Run `./scripts/setup-test-user.sh` to create the admin user
- **SCST errors**: SCST may not be installed - this is expected in test environments

For detailed testing instructions, see `TESTING-GUIDE.md`.

