test: 补齐核心包与 cmd 纯函数单测,新增无依赖 test CI - #10
Merged
Merged
Conversation
新增 13 个测试文件、扩充 3 个,测试代码 794 → 2387 行,零外部依赖 (纯函数 + 接口 mock + t.TempDir),为 go test ./... 建立可信回归网: - internal/s3path 达 100% 覆盖;config 补 Resolve 全分支(默认 profile 回退/env 展开与覆盖/path-style 强制 true/缺 key 报错) - internal/view 覆盖格式探测、suffix Range、内容嗅探不丢字节、readBounded - internal/uploader 覆盖上传路径(s3 字段改 manager.UploadAPIClient 接口 以便 mock,抽 buildKey 纯函数),连同 client.xmlTimeNormalizer(aws.HTTPClient stub)覆盖全部规范化分支 - cmd 覆盖 syncNeed 决策、matchFind 过滤、deriveDstKey、buildTree、 headLinesFromReader、parseS3、humanBytes 等 修复 uploader 中 partSize 常量未被引用等既有警告问题一并纳入。 新增 .github/workflows/test.yml:每次 push/PR 自动 go vet + go test(stable/ oldstable),此前唯一 CI 仅 release.yml 发布用、不跑任何测试。
kugouming
force-pushed
the
test/coverage-unit-tests
branch
from
September 10, 2026 00:46
f75492d to
ddc71b7
Compare
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
t.TempDir()),让go test ./...成为可信回归网internal/s3path100%、config89.5%(补 Resolve 全分支:默认 profile 回退/env 展开与覆盖/path-style 强制 true/缺 key 报错)、uploader82.1%、client52.8%、view纯函数全覆盖cmd覆盖 syncNeed 同步决策、matchFind 四类过滤、deriveDstKey、buildTree、headLinesFromReader、parseS3、humanBytes 等.github/workflows/test.yml:每次 push/PR 自动go vet+go test ./...(stable/oldstable);此前唯一 CI 仅 release.yml 发布用、不跑任何测试最小生产代码重构(行为不变)
internal/uploader:Uploader.s3字段由*s3.Client改为manager.UploadAPIClient接口以支持 mock;抽出buildKey纯函数Test plan
make test(go vet + go test ./...)全部通过go test -race通过Closes #9