Skip to content

tests: raise cosift coverage from 50% to 56%#1

Merged
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage
May 27, 2026
Merged

tests: raise cosift coverage from 50% to 56%#1
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

  • Adds 8 new *_test.go files (2,296 lines) targeting the lowest-coverage packages.
  • No production code modified; only test files added.
  • Module-average coverage: 50.4% → 56.0%.

Per-package coverage delta

Package Before After Delta
internal/config 35.3% 94.1% +58.8
internal/eval 34.7% 97.2% +62.5
internal/store 55.0% 81.5% +26.5
internal/embed 58.3% 86.8% +28.5
internal/crawler 55.9% 57.9% +2.0
cmd/cosift 33.5% 34.6% +1.1
internal/index 75.9% 75.9%
internal/rerank 81.1% 81.1%
internal/server 83.7% 84.0% +0.3
Module total 50.4% 56.0% +5.6

What's covered

  • config: Default, Load (missing file / malformed JSON / file present / empty data-dir fallback), applyEnvOverrides (PORT / COSIFT_LISTEN / COSIFT_DATA_DIR / whitespace ignored), LoadDotEnv (missing file / quoting / comments / no-override-existing).
  • eval: LoadQuerySet, LoadCorpus, LoadSummary, SaveSummary (incl. write-error), Run (with and without paraphrases, retriever errors, paraphrase tolerance), rrfFuse, score, PrintTable, Diff.
  • store (SQLite): Stats, GetDocTexts (incl. maxLen), ListDocSitemapEntries, CountByDomain, CountPassagesAllModels, CountParaphrases, CountHyDE, CountDocsWithPublishedAt, ListOutcomes, Vacuum, CountQueuedPerHost, RecrawlURL (both branches).
  • store (Pebble): Metrics, Checkpoint, PutVectorMeta / GetVectorMeta, PutVectorNode / IterateVectorNodes, PutVectorNodesBatch, ClearVectorFamily, PutPQCodebook / GetPQCodebook / PutPQCodesBatch / IteratePQCodes, ClearPQFamily, UpsertDocumentBatch (incl. empty-URL rejection + re-upsert ID stability), IterDocsLite, PurgeFrontierByHost, CorpusStats, SumDocLengths, ListDomains (filter + pagination + defaults), TopDomains, TopQueuedHosts, GetDocMeta.
  • embed: OpenAIClient.Model/Dim, NewOpenAIChat URL normalization, RoundRobinEmbedder (empty/single/distributing), ThrottledEmbedder (max<=0 unwraps, concurrency-cap actually enforced, ctx-cancel during queue), BatchingEmbedder (defaults, single-call, empty, coalescing, inner-error propagation), CachedEmbedder hit/miss accounting on disk and in-memory.
  • crawler: parseProxies (empty, malformed, no-host skipping), Robots.Allowed against an httptest.NewServer (disallow / allow-overrides-disallow / crawl-delay / bad URL), Robots.Sitemaps, robots cache (one fetch across many calls), 404-treated-as-empty, parseRobots corner cases.
  • cmd/cosift (pure helpers): authStatus, resolveAPIKey (slot precedence + OPENAI / OPENAI_API_KEY fallback), resolveEmbedAPIKey, firstEnv, contains, chunkerWith, sqrt, randUnit (magnitude + determinism), percentiles, sumDur, newSeededRand, benchResult.formatHuman (all modes + unknown fallback), sortedModes, union, neutralVocabForDistractors, generateDistractorText.

Notes / observations

  • The 70% target was not reachable from test-only changes: cmd/cosift is 12.6k lines (38% of the codebase) and most uncovered code paths are top-level command handlers that wire a live crawler.Crawler, store.Store, and HTTP server together and depend on an OpenAI-shaped backend. Reaching them needs either OpenAI access or extensive HTTP-fake scaffolding beyond the scope of this PR.
  • One small observation while reading: store.OpenMemory records path = ":memory:" but the migration path checks columnExists via raw SQL — works fine, just notable that the in-memory store inherits the full migration code path.
  • No tests touch the network; all HTTP-using tests use httptest.NewServer.
  • The repo's .env file (gitignored) was not read, modified, or referenced.

Test plan

  • go test -race -count=1 -timeout 120s ./... passes locally (verified)
  • CI codecov shows the coverage delta on each touched package

@TeoSlayer TeoSlayer merged commit ca74b1a into main May 27, 2026
2 checks passed
@TeoSlayer TeoSlayer deleted the add-test-coverage branch May 27, 2026 23:43
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

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.

2 participants