test: ensure unit tests leave zero traces (DB + disk) (#951)#952
Merged
Conversation
Tests were leaking MongoDB projects and on-disk directories: - A project stays in getProjectList() as long as any document carries its name, including the hidden <projectName>__config__ Cache document created on every Project() construction. Teardowns deleted only measurement docs, so the config doc kept every project alive. - Project.__init__ unconditionally creates ~/.hera/<projectName>; nothing removed it. - The session fixture persisted an ephemeral mkdtemp path into the durable DB config, so later Project() opens resurrected the tmp dir via makedirs. Fix: - Add purge primitives that delete all docs (incl. the config doc, via the collection layer) and remove on-disk dirs. - Add a session-scoped autouse safety-net that purges every project created during the session plus leftover test-named projects/dirs. Only touches test artifacts; defaultProject and pre-existing data are never modified. - Pass filesDirectory at construction so ~/.hera/<name> is never created, and purge the config doc on teardown so tmp dirs cannot be resurrected. - dynamic_loading conftest now purges the DB, not just the disk dir. Verified: 275 passed; zero new DB/dir/tmp artifacts; idempotent across runs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Tests were leaking MongoDB projects and on-disk directories:
Fix:
Verified: 275 passed; zero new DB/dir/tmp artifacts; idempotent across runs.