test: add testing infrastructure and improve coverage (16% to 51%) - #16
Merged
Conversation
Cherry-pick valuable testing foundations from the test coverage audit (PR #15), excluding the over-engineered factory pattern and session documentation. Included: - Mock infrastructure (auth/mock package with concurrency-safe mocks) - Interface definitions for API, Auth, Config, Output (for future DI) - Simple mocks package for testing command layer - Test utility helpers (CI detection) - Config provider wrapper (standalone-useful abstraction) - Output wrapper for testable formatting - Test suites for: api (ratelimit, retry, users), auth/mock, cache, cmd (all 15 commands), config, errors, output (formatter, table, wrapper), version - Testify dependency (stretchr/testify) Excluded from PR #15: - Factory pattern (~9,600 LOC of duplicated command implementations) - Base command abstraction (internal/cmd/base/) - 12 session-artifact documentation files - CI workflow rewrite - Source code changes that modified function signatures for DI Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 24, 2026
On Windows, os.Mkdir ignores the 0555 permission mode (CreateDirectory discards it), so the read-only setup in the "handles permission errors" subtest never takes effect. The command then succeeds, assert.Error fails non-fatally, and the subsequent err.Error() call panics on the nil error, crashing the entire internal/cmd test binary. Fixes: - Skip the permission-bit subtest on Windows and upgrade assert.Error to require.Error so a nil error can never be dereferenced again. - In the config symlink subtest, skip on Windows when os.Symlink fails, since symlink creation there can require elevation. - gofmt cleanup of pre-existing trailing whitespace in both files. Co-Authored-By: Claude Fable 5 <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
Focused extraction of valuable testing infrastructure from the test coverage audit (PR #15), without the over-engineered factory pattern that bloated it to 24K lines.
What's Included
Testing infrastructure:
internal/auth/mock/) — concurrency-safe, token expiry simulation, behavioral verificationinternal/interfaces/) for API, Auth, Config, Output — enables future dependency injectioninternal/mocks/) for auth, config, outputinternal/testutil/) for CI detectionstretchr/testifydependencyTest suites for:
Standalone source additions:
internal/config/provider.go— ConfigProvider wrapper (useful for DI)internal/output/wrapper.go— testable output formatting wrapperWhat's Excluded (from PR #15)
internal/cmd/factory/) — ~9,600 LOC of duplicated command implementationsinternal/cmd/base/)Coverage by Package
Test plan
go build ./cmd/cu— builds cleanlygo vet ./...— no issuesgo test ./...— all tests passContext
This supersedes the testing portion of PR #15. After this merges, PR #15 should be closed — its remaining value (factory pattern) is better pursued as a separate, more focused effort if/when dependency injection is needed.
🤖 Generated with Claude Code