Skip to content

fix(test): fix all 14 pre-existing test failures, add test isolation#29

Open
mldangelo wants to merge 1 commit intomainfrom
fix/pre-existing-test-failures
Open

fix(test): fix all 14 pre-existing test failures, add test isolation#29
mldangelo wants to merge 1 commit intomainfrom
fix/pre-existing-test-failures

Conversation

@mldangelo
Copy link
Member

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

Failure Count Cause
Config parsing (Parse session_name, etc.) 5 Single-quoted '$TEST_CONFIG' prevented variable expansion inside run_test's eval — yq tried to open the literal string $TEST_CONFIG
Config without config file 1 Test expected No config|not found but user's real ~/.crabcode/config.yaml existed
Ticket validation (Ticket rejects semicolon, etc.) 5 crab ticket routes through load_config + validate_config before reaching ticket validation — failed at "Missing required config"
ws ticket tests 2 Same config dependency
Unknown subcommand 1 crab 1 foobar hit config validation before reaching subcommand handler

Fixes

  • Test isolation: Backup/restore ~/.crabcode/ via trap EXIT so tests never depend on or corrupt user config
  • Config parsing quoting: Use \$(yq ...) so expansion happens at eval time
  • Minimal project config: Create a temp git repo + project YAML for tests needing config validation
  • Pattern broadening: Match No projects in addition to No config|not found
  • Subcommand test: Route through ws 1 foobar which reaches the handler properly

Results

Before: 11 passed, 14 failed (25 total)
After:  54 passed,  0 failed (54 total)

Test plan

  • make test — 54/54 passing
  • Ran twice to verify stability
  • Verified user config restored after test run
  • No test depends on external state (tmux, Docker, network)

🤖 Generated with Claude Code

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

1 participant

Comments