fix(test): fix all 14 pre-existing test failures, add test isolation#29
Open
fix(test): fix all 14 pre-existing test failures, add test isolation#29
Conversation
Root causes fixed: - Config parsing tests: single-quoted $TEST_CONFIG prevented variable expansion inside run_test's eval, so yq opened literal "$TEST_CONFIG" - Config without config: test assumed no ~/.crabcode/ exists but user config was present; broadened pattern to match "No projects" output - Ticket/subcommand tests: commands hit load_config + validate_config before reaching validation logic, failing with "Missing required config" since no project was configured - Unknown subcommand: same config dependency; changed to use "ws 1 foobar" which routes through the ws handler properly Fixes applied: - Add test isolation: backup/restore ~/.crabcode via trap EXIT so tests never pollute or depend on user's real config - Fix yq quoting: use escaped \$(yq ...) so expansion happens at eval time, not parse time - Create minimal project config (temp git repo + project yaml) for tests that require config validation - Guard ticket tests behind yq check since they need project config - Clean up temp repos on exit Also includes the 29 new tests from PR #28 (alias, alias resolution, msg) with the same isolation improvements. Results: 54 passed, 0 failed (was: 11 passed, 14 failed) Co-Authored-By: Claude Opus 4.6 <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.
Summary
Fixes all 14 pre-existing test failures and adds proper test isolation. Supersedes #28 (includes those 29 new tests with the same fixes).
Root causes
Parse session_name, etc.)'$TEST_CONFIG'prevented variable expansion insiderun_test'seval— yq tried to open the literal string$TEST_CONFIGNo config|not foundbut user's real~/.crabcode/config.yamlexistedTicket rejects semicolon, etc.)crab ticketroutes throughload_config+validate_configbefore reaching ticket validation — failed at "Missing required config"crab 1 foobarhit config validation before reaching subcommand handlerFixes
~/.crabcode/viatrap EXITso tests never depend on or corrupt user config\$(yq ...)so expansion happens at eval timeNo projectsin addition toNo config|not foundws 1 foobarwhich reaches the handler properlyResults
Test plan
make test— 54/54 passing🤖 Generated with Claude Code