Skip to content

test: no API test can open the real ~/.claude_karma/metadata.db (#124 part 1) - #125

Merged
JayantDevkar merged 1 commit into
mainfrom
fix/124-test-db-isolation
Oct 21, 2026
Merged

JayantDevkar merged 1 commit into
mainfrom
fix/124-test-db-isolation

Conversation

@JayantDevkar

Copy link
Copy Markdown
Owner

Problem

Five tests in tests/api/test_set_session_title.py open the real ~/.claude_karma/metadata.db through the title cache, and test_set_title_success runs ensure_schema on it via get_writer_db(). A contributor running the suite on a schema-changing branch migrates their own live DB without noticing (part 1 of #124). #123 isolated claude_base but not karma_base, which is where the DB path comes from.

Changes

  • tests/api/conftest.py: a second autouse fixture redirects Settings.karma_base to a per-test temp dir, which covers both the title cache and sqlite_db_path, and resets the writer singleton before and after each test. Test code only.

Verification

A sqlite3.connect spy over the full api suite, recording every path under ~/.claude_karma:

connections to the real DB
before 5 (the five test_set_session_title tests)
after 0

Full suite without the spy: 1977 passed, 6 skipped in 8.4 s. ruff check tests/ and ruff format --check clean.

Follow-ups

Part 2 of #124 (spawned_at NOT NULL failure in the shells extractor on real JSONL) stays open.

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.

1 participant