Skip to content

test: raise coverage for covers, abs, calibre and opds - #3034

Merged
vavallee merged 3 commits into
mainfrom
test/coverage-integrations
Oct 6, 2026
Merged

vavallee merged 3 commits into
mainfrom
test/coverage-integrations

Conversation

@vavallee

@vavallee vavallee commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Summary

Test only. No production code changes, so no changelog fragment.

Package Before After
internal/covers 66.2% 87.3%
internal/abs 71.3% 87.4%
internal/calibre 76.7% 88.9%
internal/opds 78.8% 99.6%

What the new *_coverage_test.go files exercise:

  • covers: every image format, the 10 MB cap (and exactly 10 MB accepted), damaged file rewrite, rename failure cleaning up its temp file, unwritable and misconfigured stores.
  • abs client: API error decoding variants, malformed JSON, 5xx retry and timeout retry with the backoff cut short by context cancellation (no real waits), SSRF refusal of link-local and metadata base URLs, ScanNotifier reading credentials at call time.
  • abs import: rollback restoring rows, upserts, author matcher, enumerator checkpoints, file inspection.
  • calibre: pull delivery, plugin client errors, cover materialisation, syncer, rollback.
  • opds: per user scoping in every feed (authors, author, series list, series, recent, book) including legacy owner 0 rows and ErrNotFound instead of empty feeds for other users' entities, plus store error propagation.

All remote APIs are httptest servers or scripted transports; files live in temp dirs; DB tests use db.OpenMemory.

Test plan

  • gofmt -l clean
  • go vet on the four packages
  • golangci-lint v2.11.4 on the four packages: 0 issues
  • go test -count=1 -cover on the four packages: pass
  • go test -race -count=1 on the four packages: pass

No production bugs surfaced.

🤖 Generated with Claude Code

https://claude.ai/code/session_016fJcCVbNnKsmj2MAAMwWj9

vavallee and others added 2 commits October 6, 2026 14:53
Test only change. Adds *_coverage_test.go files using httptest servers,
scripted transports, temp dirs and the in memory DB.

covers  66.2% -> 87.3%
abs     71.3% -> 87.4%
calibre 76.7% -> 88.9%
opds    78.8% -> 99.6%

Covers HTTP error decoding, malformed JSON, retry and backoff cut short by
context cancellation, size caps, SSRF refusals for the ABS base URL,
per user scoping in every OPDS feed, and rollback, pull delivery and
plugin client error paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016fJcCVbNnKsmj2MAAMwWj9
Signed-off-by: vavallee <vavallee@protonmail.com>
Raise the cancelled backoff bounds from 100ms to 2s so a loaded CI
runner cannot trip them, and pin the normalized alias match to the
"normalized_alias" tier the matcher actually returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016fJcCVbNnKsmj2MAAMwWj9
Signed-off-by: vavallee <vavallee@protonmail.com>
@vavallee
vavallee enabled auto-merge (squash) October 6, 2026 17:57

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-only PR (+5569 / 0). No production code touched, all additions are *_coverage_test.go files. Notes below.

OPDS user scoping (highest-priority area) — the new tests in internal/opds/builder_coverage_test.go cover the properties that matter most:

  • Every feed type (authors, author, series list, series, recent, book) is exercised for a scoped user, an admin (user 0), and the legacy owner-0 rows.
  • Cross-user entity access correctly returns ErrNotFound rather than an empty feed — this is the right behaviour; an empty feed would leak existence.
  • TestBuildSeries_SkipsBooksThatFailToLoad (line 5583): when GetByID returns a store error, the series is surfaced as ErrNotFound for the requesting user. That conflates a real storage failure with "no accessible books", which could silently hide transient DB errors. This is testing existing production behaviour, not new code, so not a blocker — but worth a glance to confirm the BuildSeries implementation intentionally swallows that error.

ABS client / SSRF test (TestValidateBaseURLSecure, line 82): link-local IPv4 (169.254.169.254) and IPv6 (fe80::1) are both refused. Good.

Test infra — db.OpenMemory() throughout, httptest.NewServer for all remote APIs, t.TempDir() for file tests, SQLite trigger injection (covImpEnv.failOn) for narrow write-failure paths. All correct patterns.

ScanNotifier DB-close behaviour (TestScanNotifier_Lifecycle, line 517): a settings read failure after database.Close() is expected to silently act as "unconfigured" rather than return an error. The test is documenting existing behaviour; fine as-is.

No new dependencies, no production code changes.

— 🤖 Bindery triage bot (automated). Reply to correct me; a human will see it.

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vavallee
vavallee merged commit c02fa85 into main Oct 6, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant