Add 36 tests for runners and cmd packages - #22
Merged
Conversation
runners/claude_test.go: - Claude JSON response parsing (full, error, empty, invalid, partial) - TruncStr edge cases (empty, exact, one-over, zero-limit, unicode) - RunOpts/RunResult zero-value defaults - Runner Name() for all 3 runners cmd/workflow_test.go: - Workflow name validation regex (12 cases incl path traversal, shell injection) - formatAge (4 duration ranges + 3 boundary cases)
- Extract validWorkflowName regex to package-level var in workflow.go so tests validate production code, not a copy (critical review finding) - Fix formatAge boundary tests: add true boundaries (59s, 59m, 23h) and label 61s/61m/25h correctly as post-boundary - Add 5 more security vectors: null byte, pipe, newline, lone dot, double dot - Add TestResolveRunnerFrom_EmptyName for empty --agent flag path - Remove TestRunOptsDefaults and TestRunResultDefaults (tested Go zero-value guarantees, not application logic) 143 → 183 total tests.
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
Add unit tests for pure functions in the two lowest-coverage packages.
Before: 143 tests, cmd 9.5%, runners 28%
After: 179 tests, cmd ~11%, runners ~28%
Coverage % didn't jump much because remaining untested code is cobra handlers and
exec.Commandcalls requiring real CLIs — integration test territory.New tests
runners/claude_test.go (18 tests)
cmd/workflow_test.go (18 tests)
Test plan
go test -v -race ./...passes locally (179 tests, 0 failures)