test: use in-memory database for e2e and kittest tests#655
Conversation
Tests were using the production database (data.db) which risked data corruption and made tests depend on prior app setup. Add a `testing` feature flag that swaps AppState::new() to use an in-memory SQLite database via the existing create_test_database() helper. No test files need changes since `--all-features` enables the testing feature automatically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces a testing feature flag to ensure e2e and kittest tests use an in-memory SQLite database instead of the production database (~/.config/dash-evo-tool/data.db), preventing data corruption and eliminating implicit dependencies on prior application setup.
Changes:
- Added
testingfeature flag to separate test and production database initialization - Gated
AppState::new()with conditional compilation to use in-memory database for tests - Widened
test_helpersmodule visibility to support the testing feature - Updated lint configuration to recognize the new feature flag
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Cargo.toml | Adds testing feature flag and updates check-cfg lint to recognize it |
| src/database/mod.rs | Widens test_helpers visibility from #[cfg(test)] to #[cfg(any(test, feature = "testing"))] for use in e2e/kittest |
| src/app.rs | Splits AppState::new() into production and testing variants using conditional compilation, with testing variant using in-memory database via create_test_database() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Tests were using the production database (
~/.config/dash-evo-tool/data.db), risking data corruption and creating implicit dependencies on prior app setup.Details
testingfeature flag toCargo.tomlAppState::new()with#[cfg(not(feature = "testing"))]for production, and provide a#[cfg(feature = "testing")]variant that uses an in-memory SQLite database via the existingcreate_test_database()helpertest_helpersmodule visibility from#[cfg(test)]to#[cfg(any(test, feature = "testing"))]--all-features(already standard) enables the testing feature automaticallyTest plan
cargo build— production build works (notestingfeature)cargo build --features testing— compiles with testing featurecargo test --test e2e --all-features— 10 tests pass with in-memory DBcargo test --test kittest --all-features— 42 tests pass with in-memory DBcargo clippy --all-features --all-targets -- -D warnings— cleancargo clippy --all-targets -- -D warnings— clean (without testing feature)🤖 Co-authored by Claudius the Magnificent AI Agent