test: add unit tests for alias, alias resolution, and msg commands#28
Open
test: add unit tests for alias, alias resolution, and msg commands#28
Conversation
Add 29 new unit tests covering three previously untested features: Alias command tests (17): - List empty state, set/rm argument validation - Name validation (spaces, special chars rejected; hyphens, underscores ok) - Set, list, overwrite, remove operations - Persistence in global config verified via yq - Unknown subcommand handling Alias resolution tests (2): - Single-word alias resolves to target command - Multi-word alias resolves correctly Msg command tests (10): - Help output, status display, say toggle (on/off/state) - Unknown subcommand handling - Graceful behavior for read/history without active relay All 29 new tests pass. Pre-existing test failures unchanged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mldangelo
added a commit
that referenced
this pull request
Feb 14, 2026
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>
4 tasks
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
make test)Alias command tests (17 tests)
~/.crabcode/config.yamlAlias resolution tests (2 tests)
crab <alias>resolves to the target command at runtimeMsg command tests (10 tests)
Test plan
make test— all 29 new tests passgit stashcomparison🤖 Generated with Claude Code