bottest/PROMPT.md

152 lines
3.3 KiB
Markdown
Raw Normal View History

2026-01-22 20:24:08 -03:00
# BotTest Development Guide
2025-12-06 11:05:57 -03:00
2026-01-22 20:24:08 -03:00
**Version:** 6.2.0
2025-12-06 11:05:57 -03:00
**Purpose:** Test infrastructure for General Bots ecosystem
---
2025-12-21 23:40:44 -03:00
## ZERO TOLERANCE POLICY
**EVERY SINGLE WARNING MUST BE FIXED. NO EXCEPTIONS.**
---
2026-01-22 20:24:08 -03:00
## ❌ ABSOLUTE PROHIBITIONS
2025-12-21 23:40:44 -03:00
```
2026-01-22 20:24:08 -03:00
❌ NEVER use #![allow()] or #[allow()] in source code
❌ NEVER use _ prefix for unused variables - DELETE or USE them
2025-12-21 23:40:44 -03:00
❌ NEVER use .unwrap() - use ? or proper error handling
❌ NEVER use .expect() - use ? or proper error handling
2026-01-22 20:24:08 -03:00
❌ NEVER use panic!() or unreachable!()
❌ NEVER use todo!() or unimplemented!()
❌ NEVER leave unused imports or dead code
❌ NEVER add comments - code must be self-documenting
2025-12-21 23:40:44 -03:00
```
---
2026-01-22 20:24:08 -03:00
## 🏗️ ARCHITECTURE
2025-12-06 11:05:57 -03:00
2026-01-22 20:24:08 -03:00
E2E tests use `USE_BOTSERVER_BOOTSTRAP=1` mode. The botserver handles all service installation during bootstrap.
2025-12-06 11:05:57 -03:00
```
TestHarness::full() / E2E Tests
2025-12-06 11:05:57 -03:00
├── Allocate unique ports (15000+)
├── Create ./tmp/bottest-{uuid}/
├── Start mock servers only
2025-12-06 11:05:57 -03:00
│ ├── MockZitadel (wiremock)
│ └── MockLLM (wiremock)
├── Start botserver with --stack-path
│ └── Botserver auto-installs:
│ ├── PostgreSQL (tables)
│ ├── MinIO (drive)
│ └── Redis (cache)
2025-12-06 11:05:57 -03:00
└── Return TestContext
```
---
2026-01-22 20:24:08 -03:00
## 🧪 TEST CATEGORIES
2025-12-06 11:05:57 -03:00
### Unit Tests (no services)
```rust
#[test]
fn test_pure_logic() {
// No TestHarness needed
}
```
### Integration Tests (with services)
```rust
#[tokio::test]
async fn test_with_database() {
2026-01-22 20:24:08 -03:00
let ctx = TestHarness::quick().await?;
let pool = ctx.db_pool().await?;
2025-12-06 11:05:57 -03:00
// Use real database
}
```
### E2E Tests (with browser)
```rust
#[tokio::test]
async fn test_user_flow() {
2026-01-22 20:24:08 -03:00
let ctx = TestHarness::full().await?;
let server = ctx.start_botserver().await?;
let browser = Browser::new().await?;
2025-12-06 11:05:57 -03:00
// Automate browser
}
```
---
2026-01-22 20:24:08 -03:00
## 🎭 MOCK SERVER PATTERNS
2025-12-06 11:05:57 -03:00
### Expect specific calls
```rust
ctx.mock_llm().expect_completion("hello", "Hi there!");
```
### Verify calls were made
```rust
ctx.mock_llm().assert_called_times(2);
```
### Simulate errors
```rust
ctx.mock_llm().next_call_fails(500, "Internal error");
```
---
2026-01-22 20:24:08 -03:00
## 🏭 FIXTURE PATTERNS
2025-12-06 11:05:57 -03:00
### Factory functions
```rust
let user = fixtures::admin_user();
let bot = fixtures::bot_with_kb();
let session = fixtures::active_session(&user, &bot);
```
### Insert into database
```rust
ctx.insert(&user).await;
ctx.insert(&bot).await;
```
---
2026-01-22 20:24:08 -03:00
## ⚡ PARALLEL SAFETY
2025-12-06 11:05:57 -03:00
- Each test gets unique ports via PortAllocator
- Each test gets unique temp directory
- No shared state between tests
- Safe to run with `cargo test -j 8`
---
2026-01-22 20:24:08 -03:00
## 📖 DOCUMENTATION LOCATION
2026-01-22 20:24:08 -03:00
All documentation goes in `botbook/src/17-testing/`:
- `README.md` - Testing overview
- `e2e-testing.md` - E2E test guide
- `architecture.md` - Testing architecture
- `best-practices.md` - Best practices
2025-12-21 23:40:44 -03:00
---
2026-01-22 20:24:08 -03:00
## 🔑 REMEMBER
2025-12-21 23:40:44 -03:00
- **ZERO WARNINGS** - Every clippy warning must be fixed
2026-01-22 20:24:08 -03:00
- **NO ALLOW ATTRIBUTES** - Never silence warnings
- **NO DEAD CODE** - Delete unused code
- **NO UNWRAP/EXPECT** - Use ? operator
- **INLINE FORMAT ARGS** - `format!("{name}")` not `format!("{}", name)`
2025-12-21 23:40:44 -03:00
- **USE SELF** - In impl blocks, use Self not the type name
2026-01-22 20:24:08 -03:00
- **Reuse bootstrap** - Don't duplicate botserver installation logic
- **Version 6.2.0** - do not change without approval