refactor: extract testable packages and increase coverage to 70%#19
Merged
refactor: extract testable packages and increase coverage to 70%#19
Conversation
Add unit tests for previously uncovered functions: - cmd/claude-sync: truncatePath, formatSize, compareVersions, getBinaryName - internal/config: ClaudeJSONPath, GetStorageConfig, IsLegacyConfig - internal/sync/state: IsEmpty, GetMCPBaseline, SetMCPBaseline, Save/Load
Move truncatePath, formatSize, compareVersions, and getBinaryName from cmd/claude-sync/main.go to internal/util/format.go as exported functions. Add comprehensive table-driven tests in internal/util/format_test.go.
Add tests for Push, Pull, Status, State, MCP sync, and gzip operations covering Tasks 3-7 of the test coverage initiative.
Measure coverage on internal/ packages (excluding cloud provider adapters that require real credentials). Set 60% threshold with current coverage at 70.7%.
1b3899b to
1d5742b
Compare
|
🎉 This PR is included in version 1.8.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
Refactors
cmd/claude-sync/main.goto extract testable business logic and adds comprehensive tests to reach 70.7% coverage on library packages (up from ~24%).Changes
internal/util/—TruncatePath,FormatSize,CompareVersions,GetBinaryNamemoved from monolithic main.go to a focused, 96.4% covered packageNewSyncerWithconstructor — dependency-injected Syncer for testing without cloud credentialsCoverage Results
internal/util(new)internal/storageinternal/cryptointernal/configinternal/syncCommits
test: increase test coverage from 21.6% to 24.3%— initial config/state testsrefactor: extract helpers to internal/util package— move pure functions out of main.gofeat: add NewSyncerWith for dependency-injected testing— testable Syncer constructortest: add comprehensive Syncer operation tests— Push/Pull/Status/MCP/gzip testsci: add coverage threshold check on library packages— CI enforcement at 60%