Repository navigation
test: isolate API tests from the real ~/.claude (fixes #93) - #123
Merged
Merged
Conversation
…ger ingests it (fixes #93)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Six tests in
test_background_shells_router.pyfail on any machine with real Claude Code data and take 40 to 50 s each, while CI stays green (#93).GET /shellscalls_maybe_sync(), which scanssettings.projects_dir, and the fixture isolated the DB path but not the ingest source, so the real~/.claude/projectswas ingested into the temp DB. The authors of #97 and #101 both hit this and had to explain it in their PR bodies.Changes
tests/api/conftest.py: an autouse fixture pointssettings.claude_baseat an empty per-test temp dir, so no API test can read the real~/.claude. With noprojects/subdir, an accidentalsync_all_projects()returns early, as it does on CI.test_background_shells_router.py: the old fixture becomesshells_appwith the lazy sync left live and the debounce clock reset;clientstubs_maybe_sync, so every existing query test is unchanged. A newTestListShellsLazySyncbuilds a fake projects dir with one background Bash session and assertsGET /shellsingests it (a negative control stubbingsync_all_projectsfails with0 == 1).background_shellsis the only router that syncs lazily;admin.pysyncs only on the explicitPOST /admin/reindex.Test code only. No production change.
Verification
On this machine with real data, same interpreter:
test_background_shells_router.pyapisuiteruff check tests/ routers/clean,ruff format --checkclean.Follow-ups
tests/api/test_set_session_title.pyopen the real~/.claude_karma/metadata.dbthroughservices/session_title_cache.py, andtest_set_title_successrunsensure_schemaon it viaget_writer_db(). No rows change (fake uuid), but it is the actual leak the memory note blamed on the app lifespan. Tracked in a separate issue.NOT NULL constraint failed: background_shells.spawned_atfor several real sessions; looks like a separate extractor bug on real JSONL. Same issue.