test(network): cover MemoRelationAdapter for v0.24/v0.25/v0.26 parsing#9
Draft
whtis wants to merge 1 commit into
Draft
test(network): cover MemoRelationAdapter for v0.24/v0.25/v0.26 parsing#9whtis wants to merge 1 commit into
whtis wants to merge 1 commit into
Conversation
`MemoRelationAdapter` is the seam between the Memos server's three
different on-the-wire shapes for memo relations:
- v0.24 sometimes ships `memo` / `relatedMemo` as bare strings
- v0.24/v0.25 ship `type` as a numeric proto enum (1 = REFERENCE,
2 = COMMENT)
- v0.26 ships `memo` / `relatedMemo` as objects with name/uid/snippet
and `type` as a string
A regression in this adapter silently breaks comment threads, reference
chips, and the memo detail page across every supported server version,
but until now it had zero test coverage.
Adds 10 unit tests pinning every parsing branch (string / object /
numeric / null memo fields; string / numeric / unknown / null type
fields; snake_case alias; unknown-field skip; round-trip toJson),
plus the JUnit test-implementation wiring needed for `:core:network`
to host them. No production code changes.
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.
改动概述
MemoRelationAdapter— the custom Moshi adapter that handles the three on-the-wire shapes Memos servers ship for memo relations across v0.24 / v0.25 / v0.26.testImplementationon:core:network(first test-implementation dependency in the repo, so also adds thejunitentry togradle/libs.versions.toml).为什么
Regressions in
MemoRelationAdapterare silent and version-specific: comment threads or reference chips just stop rendering on one server build. Pinning every branch (string memo / object memo / numeric memo / null; string type / numeric 1+2 / numeric unknown / null;related_memosnake_case alias; unknown-field skip; round-triptoJson) makes any future refactor cheap to verify.测试
ANDROID_HOME未设置,~/Library/Android/sdk不存在),gradle 任务在 SDK location 检查阶段就 fail 了。MemoRelationAdapter.readMemoField/readTypeField的每个when分支一一对应,目测可读。Next step for reviewer
./gradlew :core:network:testDebugUnitTestlocally — confirm 10 green.gh pr ready→ merge.🌙 night-shift 自动生成;draft 状态等待人工 review。