Skip to content

test: ensure unit tests leave zero traces (DB + disk) (#951)#952

Merged
lior-antonov merged 1 commit into
masterfrom
issue951
Jun 25, 2026
Merged

test: ensure unit tests leave zero traces (DB + disk) (#951)#952
lior-antonov merged 1 commit into
masterfrom
issue951

Conversation

@ilayfalach

Copy link
Copy Markdown
Collaborator

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 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/; 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/ 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.

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>
@lior-antonov lior-antonov merged commit 121c019 into master Jun 25, 2026
1 check passed
@lior-antonov lior-antonov deleted the issue951 branch June 25, 2026 07:54
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