Add end-to-end executor integration tests and shared db fixture#59
Merged
Conversation
The executor's database helpers (fetch_pending, update_command, update_cwd) were only covered indirectly via stubs. Add real database-backed tests that: - submit a command, claim it with fetch_pending, run it through handle_command, and assert the commands row is marked done with output, exit code, and completed_at populated; - run a `cd` command and assert the environments row is updated; - assert fetch_pending returns None when there is no pending work. Introduce tests/conftest.py with a reusable db_conn fixture and install_schema helper so modules no longer reimplement schema setup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BixPb34oe2Ae5cXuz9WxbP
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.
Summary
The executor's database helpers —
fetch_pending,update_command,update_cwd— were only covered indirectly (the unit tests stub them out).This adds real database-backed tests that drive a command through the full
executor path and verify the persisted result.
New tests (
tests/test_executor_integration.py)fetch_pending(verifyingit flips to
running), execute it viahandle_command, then assert thecommandsrow isdonewith the captured output,exit_code = 0, andcompleted_atpopulated.cdupdates environment — runcd workdirand assert theenvironmentsrow's
cwdis updated to the new directory.fetch_pendingreturnsNonewhen there is no pending work.Infrastructure
tests/conftest.pywith a reusabledb_connfixture andinstall_schemahelper, so test modules no longer have to reimplement schemasetup. (Existing modules keep their current fixtures; they can migrate to the
shared one in a later cleanup.)
Verification
🤖 Generated with Claude Code
Generated by Claude Code