ワンクリックで
testing
Use when adding unit tests, running cargo test, checking test coverage, or matching Python ground truth fixtures for utils.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when adding unit tests, running cargo test, checking test coverage, or matching Python ground truth fixtures for utils.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when selecting a Gemini model, checking rate limits or quotas, configuring the gemini-rust crate, or debugging model name mismatches.
Create new Kiro skills (Agent Skills). Use when asked to create a skill, write a SKILL.md, add a new workflow to .kiro/skills/, or package agent instructions as a reusable skill.
Use when creating a release, bumping the version, tagging a commit, or working with the GitHub Actions release workflow for rs-summarizer.
Use when editing or creating Askama HTML templates, adding template variables, fixing compile-time template errors, or working with HTMX attributes in templates.
Use when working with tokio::spawn background tasks, the summarization pipeline, task state transitions, or the mark_error/mark_summary_done pattern.
Use when building, running, linting with clippy, formatting with rustfmt, or running cargo commands for the rs-summarizer project.
| name | testing |
| description | Use when adding unit tests, running cargo test, checking test coverage, or matching Python ground truth fixtures for utils. |
rs-summarizer has two test layers: unit tests (fast, offline, in src/) and integration tests (require network + API keys, in tests/). Unit tests validate pure logic against Python ground truth. Integration tests exercise the real external services and verify the full pipeline lifecycle.
# All unit tests (fast, no network)
cargo test
# Specific module
cargo test utils::url_validator
cargo test services::summary
cargo test cache
# Integration tests (require network + API key)
GEMINI_API_KEY=$(cat ~/api_key.txt) cargo test --test integration_pipeline -- --ignored
cargo test --test integration_transcript -- --ignored
# Single integration test with output
GEMINI_API_KEY=$(cat ~/api_key.txt) cargo test --test integration_pipeline test_summary_done_flag_transitions -- --ignored --nocapture
# All tests including integration
GEMINI_API_KEY=$(cat ~/api_key.txt) cargo test -- --include-ignored
Unit tests live alongside the code in #[cfg(test)] mod tests blocks. They cover:
t01_validate_youtube_url.pyt02_parse_vtt_file.py)tests/fixtures/cW3tzRzTHKI.en.vtt**bold** → *bold* conversion## Heading → *Heading* conversiont03_convert_markdown_to_youtube_format.pyt= offsett04_convert_html_timestamps_to_youtube_links.pyIntegration tests live in tests/ and are all marked #[ignore] (require external services).
Tests yt-dlp subtitle download. Requires network + Firefox cookies.
| Test | What it verifies |
|---|---|
test_list_subtitles_real_video | yt-dlp can list available subtitle languages |
test_download_auto_subtitles | VTT file is created on disk for auto-generated captions |
test_full_transcript_pipeline | List → download → parse produces valid timestamped transcript |
Tests the full summarization pipeline. Requires network + GEMINI_API_KEY.
| Test | What it verifies | Needs API? |
|---|---|---|
test_transcript_download | TranscriptService downloads real video transcript | No (network only) |
test_summary_generation | Gemini generates summary, tokens/cost recorded | Yes |
test_embedding_computation | Embedding API returns correct dimensions | Yes |
test_cosine_similarity_integration | Cosine similarity math (no network) | No |
test_full_pipeline_end_to_end | Transcript → summary → YouTube format → embedding | Yes |
test_summary_done_flag_transitions | summary_done goes false→true after process_summary | Yes |
test_timestamps_done_after_pipeline | timestamps_done set, YouTube format populated | Yes |
test_error_sets_summary_done | Short transcript error still sets summary_done=true | No |
test_invalid_model_sets_summary_done | Unknown model error still sets summary_done=true | No |
test_polling_lifecycle_simulation | Simulates HTMX polling, verifies it terminates | Yes |
In-memory SQLite: Integration tests use db::init_db("sqlite::memory:") for isolated, fast databases.
AppState construction: Tests that exercise process_summary() build a full AppState:
async fn build_test_app_state() -> AppState {
let api_key = get_api_key();
let db_pool = db::init_db("sqlite::memory:").await.unwrap();
AppState {
db: db_pool,
model_options: Arc::new(vec![test_model()]),
model_counts: Arc::new(RwLock::new(HashMap::new())),
last_reset_day: Arc::new(RwLock::new(None)),
gemini_api_key: api_key,
}
}
Graceful rate-limit handling: Tests check error strings for 429, ResourceExhausted, or rate and skip (print + return) instead of panicking:
Err(e) => {
let err_str = e.to_string();
if err_str.contains("429") || err_str.contains("ResourceExhausted") {
println!("SKIPPED: API rate-limited: {}", err_str);
return;
}
panic!("Failed: {}", e);
}
Lifecycle simulation: The test_polling_lifecycle_simulation test spawns the background task and polls the DB in a loop (like HTMX would), asserting that summary_done eventually becomes true within a timeout.
Add to the #[cfg(test)] mod tests block in the relevant source file. No special setup needed.
tests/integration_pipeline.rs or tests/integration_transcript.rs#[tokio::test] and #[ignore]get_api_key() for Gemini testsdb::init_db("sqlite::memory:") for database--nocapture visibilitytests/integration_browser.rs#[tokio::test] and #[ignore]start_test_server() or start_test_server_with_state() for the serverseed_summaries() / seed_summary_with_timestamps() for pre-seeded dataclient.close() + geckodriver.kill()tests/fixtures/cW3tzRzTHKI.en.vtt — Real WebVTT subtitle file used for VTT parser ground-truth testing