Skip to content

test: use in-memory database for e2e and kittest tests#655

Merged
lklimek merged 1 commit into
v1.0-devfrom
test/use-in-memory-db-for-tests
Feb 25, 2026
Merged

test: use in-memory database for e2e and kittest tests#655
lklimek merged 1 commit into
v1.0-devfrom
test/use-in-memory-db-for-tests

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented Feb 25, 2026

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

  • Add testing feature flag to Cargo.toml
  • Gate AppState::new() with #[cfg(not(feature = "testing"))] for production, and provide a #[cfg(feature = "testing")] variant that uses an in-memory SQLite database via the existing create_test_database() helper
  • Widen test_helpers module visibility from #[cfg(test)] to #[cfg(any(test, feature = "testing"))]
  • Zero test file changes--all-features (already standard) enables the testing feature automatically

Test plan

  • cargo build — production build works (no testing feature)
  • cargo build --features testing — compiles with testing feature
  • cargo test --test e2e --all-features — 10 tests pass with in-memory DB
  • cargo test --test kittest --all-features — 42 tests pass with in-memory DB
  • cargo clippy --all-features --all-targets -- -D warnings — clean
  • cargo clippy --all-targets -- -D warnings — clean (without testing feature)

🤖 Co-authored by Claudius the Magnificent AI Agent

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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

Warning

Rate limit exceeded

@lklimek has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 5a13ded and b6dadcc.

📒 Files selected for processing (3)
  • Cargo.toml
  • src/app.rs
  • src/database/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/use-in-memory-db-for-tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lklimek lklimek requested a review from Copilot February 25, 2026 00:20
@lklimek lklimek marked this pull request as ready for review February 25, 2026 00:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 testing feature flag to separate test and production database initialization
  • Gated AppState::new() with conditional compilation to use in-memory database for tests
  • Widened test_helpers module 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.

@lklimek lklimek merged commit aa25793 into v1.0-dev Feb 25, 2026
8 checks passed
@lklimek lklimek deleted the test/use-in-memory-db-for-tests branch February 25, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants