test(coverage): lane 2 — sync, workers, transport & auth to >=95% #261

Merged
JMR-dev merged 2 commits from test-247-coverage-sync-workers-transport-auth into main 2026-07-03 20:17:01 +00:00
JMR-dev commented 2026-07-03 19:54:43 +00:00 (Migrated from github.com)

Coverage lane 2 (issue #247) — sync, workers, transport & auth

Test-only change (zero production changes, JaCoCo config untouched). Raises JVM unit-test LINE coverage to ≥95% for the in-scope packages.

Measured LINE coverage (:app:jacocoTestReport)

Package Before After
data/sync/** 67.0% 98.6% (437/443)
mail/** (IMAP/SMTP/Graph transport) 74.8% 96.7% (561/580)
auth/** (OAuth) 0.0% 100.0% (89/89)

Combined in-scope: 97.8% (1087/1112 lines).

Instruction/branch coverage stays lower than line coverage for this sync/worker/coroutine code — the suspend state machines and Flow collector continuations contain suspend/resume branches that don't execute under synchronous mocks (a known JaCoCo × coroutines limitation, not untested logic). Per the plan this was not chased by contorting tests, and JaCoCo config is untouched (the ratchet is owned by capstone lane #251).

What's covered (new/extended, additive)

  • Workers/sync: SendWorker outbox drain — SMTP + Graph sends, the "may-have-sent" no-retry case, Graph→SMTP fallback, staged/inline attachment pairing; MailConnectionFactory token cache/refresh (valid-reuse, expired, unknown-expiry, persist-only-when-changed, password + missing-credential errors); MailSyncer.syncAll (partial-failure semantics); SendScheduler; MailBackfiller pre-existing-row refresh branch.
  • Transport: ImapConnectionCache reuse + dropped-connection retry/clear-slot/closeAll; ImapClient fetchAttachment/setFlag/deleteMessage/idle + empty-folder / unknown-uid / STARTTLS+XOAUTH2 branches (GreenMail); GraphSender.send transport (2xx / rejection / lost-response / transmit-failure) via a test-only URLStreamHandlerFactory fake — no network, no prod seam.
  • Auth: OutlookAuthManager — two-resource token exchange, id_token email extraction (+ preferred_username fallback), refresh paths, and every failure branch (AppAuth objects built for real; only Android statics + the token-endpoint call are faked); OAuth result models.

Verification (JDK 21)

assembleDebug · testDebugUnitTest · compileDebugAndroidTestKotlin · lintDebug · ktlintCheck · detekt · jacocoTestReport — all green. JVM-only lane (no androidTest/prod changes), so CI's E2E matrix is authoritative.

Closes #247

🤖 Generated with Claude Code

## Coverage lane 2 (issue #247) — sync, workers, transport & auth Test-only change (**zero production changes**, JaCoCo config untouched). Raises JVM unit-test **LINE** coverage to ≥95% for the in-scope packages. ### Measured LINE coverage (`:app:jacocoTestReport`) | Package | Before | After | |---|---|---| | `data/sync/**` | 67.0% | **98.6%** (437/443) | | `mail/**` (IMAP/SMTP/Graph transport) | 74.8% | **96.7%** (561/580) | | `auth/**` (OAuth) | 0.0% | **100.0%** (89/89) | Combined in-scope: **97.8%** (1087/1112 lines). > Instruction/branch coverage stays lower than line coverage for this sync/worker/coroutine code — the suspend state machines and `Flow` collector continuations contain suspend/resume branches that don't execute under synchronous mocks (a known JaCoCo × coroutines limitation, not untested logic). Per the plan this was **not** chased by contorting tests, and **JaCoCo config is untouched** (the ratchet is owned by capstone lane #251). ### What's covered (new/extended, additive) - **Workers/sync:** `SendWorker` outbox drain — SMTP + Graph sends, the "may-have-sent" no-retry case, Graph→SMTP fallback, staged/inline attachment pairing; `MailConnectionFactory` token cache/refresh (valid-reuse, expired, unknown-expiry, persist-only-when-changed, password + missing-credential errors); `MailSyncer.syncAll` (partial-failure semantics); `SendScheduler`; `MailBackfiller` pre-existing-row refresh branch. - **Transport:** `ImapConnectionCache` reuse + dropped-connection retry/clear-slot/`closeAll`; `ImapClient` `fetchAttachment`/`setFlag`/`deleteMessage`/`idle` + empty-folder / unknown-uid / STARTTLS+XOAUTH2 branches (GreenMail); `GraphSender.send` transport (2xx / rejection / lost-response / transmit-failure) via a test-only `URLStreamHandlerFactory` fake — no network, no prod seam. - **Auth:** `OutlookAuthManager` — two-resource token exchange, id_token email extraction (+ `preferred_username` fallback), refresh paths, and every failure branch (AppAuth objects built for real; only Android statics + the token-endpoint call are faked); OAuth result models. ### Verification (JDK 21) `assembleDebug` · `testDebugUnitTest` · `compileDebugAndroidTestKotlin` · `lintDebug` · `ktlintCheck` · `detekt` · `jacocoTestReport` — all green. JVM-only lane (no androidTest/prod changes), so CI's E2E matrix is authoritative. Closes #247 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.