# Tests

This directory contains test scripts and utilities for the Echoes of the Ashes bot.

## Performance Testing

### test_performance.py

Performance testing script for background tasks. Generates realistic test data and measures actual performance.

**Usage:**

```bash
# Run inside Docker container
docker compose exec echoes_of_the_ashes_bot python tests/test_performance.py --players 1000 --combats 100 --items 500

# Test with existing data only (no generation)
docker compose exec echoes_of_the_ashes_bot python tests/test_performance.py --test-only

# Clean up test data
docker compose exec echoes_of_the_ashes_bot python tests/test_performance.py --cleanup
```

**Options:**
- `--players N` - Number of test players to generate (default: 1000)
- `--combats N` - Number of test combats to generate (default: 100)
- `--items N` - Number of dropped items to generate (default: 500)
- `--test-only` - Skip data generation, just run performance tests
- `--cleanup` - Remove all test data and exit

**What it tests:**
- ✅ Stamina regeneration performance (`regenerate_all_players_stamina`)
- ✅ Combat timer checks (`check_combat_timers`)
- ✅ Item decay cleanup (`decay_dropped_items`)

**Expected Results:**
- 1,000 players: <0.1s total
- 10,000 players: <1s total
- 100,000 players: <2s total

**Performance Ratings:**
- 🟢 EXCELLENT: <1s
- 🟡 GOOD: 1-3s
- 🟠 ACCEPTABLE: 3-10s
- 🔴 SLOW: >10s

## Future Tests

Additional test scripts can be added here:
- Unit tests for bot handlers
- Integration tests for game mechanics
- Load testing for concurrent users
- Database migration tests
