rust-tests
星标2
分支0
更新时间2025年12月11日 04:43
Run and debug Rust tests for glhf. Use when running tests, fixing test failures, or adding new test cases.
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Run and debug Rust tests for glhf. Use when running tests, fixing test failures, or adding new test cases.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Work with the SQLite database layer including FTS5, sqlite-vec, and schema operations. Use for database queries, indexing issues, or storage debugging.
Implement and debug semantic/vector search with model2vec-rs and sqlite-vec. Use for embedding generation, vector queries, hybrid search, or RRF fusion.
Set up the embedding model for semantic search. model2vec-rs downloads models automatically; use when build fails or model download issues occur.
| name | rust-tests |
| description | Run and debug Rust tests for glhf. Use when running tests, fixing test failures, or adding new test cases. |
cargo test
cargo test embed -- --ignored
cargo test test_name # Run tests matching name
cargo test --lib # Only library tests
cargo test --test integration # Only integration tests
cargo test -- --nocapture # Show println output
tests/
├── integration.rs # End-to-end tests
└── common/
└── mod.rs # Test utilities (TestEnv, fixtures)
src/
├── db/mod.rs # Unit tests in #[cfg(test)] mod tests
├── embed.rs # Embedding tests (#[ignore] for CI)
└── document.rs # Document struct tests
let env = TestEnv::new(); // Creates temp directory
let project = env.create_project("path"); // Creates project dir
let jsonl = env.write_jsonl(&project, "file.jsonl", &lines);
fn user_message(content: &str, session: &str) -> String
fn assistant_message(content: &str, session: &str) -> String
fn assistant_with_blocks(texts: &[&str], session: &str) -> String
fn file_history_snapshot() -> String
fn malformed_json() -> String
| Category | Location | Run Command |
|---|---|---|
| Unit tests | src/**/*.rs | cargo test --lib |
| Integration | tests/integration.rs | cargo test --test integration |
| Doc tests | src/**/*.rs | cargo test --doc |
| Embedding | src/embed.rs | cargo test embed -- --ignored |
| Benchmarks | benches/indexing.rs | cargo bench |
#[test]
fn test_database_operation() {
let env = TestEnv::new();
let db_path = env.index_dir.join("test.db");
let mut db = Database::open(&db_path).unwrap();
let doc = Document::new(
ChunkKind::Message,
"test content".to_string(),
PathBuf::from("/test"),
);
db.insert_documents(&[doc]).unwrap();
let results = db.search_fts("test", 10).unwrap();
assert_eq!(results.len(), 1);
}
#[test]
#[ignore = "Requires model download"]
fn test_embedding() {
let embedder = Embedder::new().unwrap();
let embedding = embedder.embed_query("test").unwrap();
assert_eq!(embedding.len(), 512); // Potion-base-32M dimension
}
| Error | Cause | Fix |
|---|---|---|
Failed to load model | Missing/corrupted model | Delete HF cache, re-run |
sqlite-vec not loaded | Init order | Call init_sqlite_vec() before open |
FTS5 match failed | Bad query syntax | Escape special chars |