Skip to content

tests: cmd/cosift round-3 — OpenAI mocks + populated Pebble fixture#3

Merged
TeoSlayer merged 1 commit into
mainfrom
cosift-cmd-round3
May 28, 2026
Merged

tests: cmd/cosift round-3 — OpenAI mocks + populated Pebble fixture#3
TeoSlayer merged 1 commit into
mainfrom
cosift-cmd-round3

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

Round-3 coverage push for cmd/cosift: 40.8% → 50.5% (+9.7pp).

Two reusable fixtures land in cmd/cosift/zz_round3_test.go:

  • openaiTestServer — httptest.Server speaking the OpenAI wire shape on /v1/chat/completions and /v1/embeddings. Pluggable per-test via SetChatResponse / SetEmbedDim. Embeddings are deterministic (hash of input → vector), so retrieval is reproducible.

  • populatedPebbleStore — temp Pebble dir seeded with 6 small docs, BM25 postings, and an HNSW graph built from the same deterministic vectors. A makeServer(mock) helper wires the fixture into a pebbleHTTP so handlers can run in-process against httptest.Recorder without standing up a real listener.

Functions moved from 0% → covered

Function Coverage
runStats (pebble path) 79%
runBenchPQ 72%
runHNSWRebuild 67%
runRefreshDue 50%
runCompactIndex 77%
runCrawlStatus 75%
runPebbleInfo 80%
handleSearch 53%
handleFindSimilar 52%
handleAnswer 50%
handleResearch 58%
handleQuery 81%
handleAnswerPOST / handleResearchPOST / handleFindSimilarPOST covered
handleDomains / handleQueue covered
paraphraseQuery 87%
applyMMRPermutation 90%
parseQueryPlan 91%
parseRetrievalFilters 100%
retrievalFilters.allow 100%
sortHitsByDate 90%
truncateForPromptLite 100%
synthRequest.toValues 100%
doChat 86%

Constraints

  • Only a new *_test.go file (cmd/cosift/zz_round3_test.go, 1290 lines).
  • No production source touched.
  • All existing tests still pass under -race.

Test plan

  • go test -cover -race -count=1 -timeout 180s ./cmd/cosift/... → 50.5%
  • go vet ./cmd/cosift/... clean
  • Re-run confirms stable coverage number across runs

Coverage 40.8% → 50.5% via two reusable fixtures:

  - openaiTestServer: httptest.Server speaking /v1/chat/completions and
    /v1/embeddings, with per-test SetChatResponse / SetEmbedDim overrides
    and deterministic vectors so retrieval is reproducible.

  - populatedPebbleStore: temp Pebble dir with 6 docs, BM25 postings,
    and an HNSW graph built from the same deterministic vectors. Plugs
    into a pebbleHTTP via makeServer(mock) — handlers run in-process
    against httptest.Recorder without standing up a real server.

Functions moved from 0% (selection):
  runStats (pebble) 79%, runBenchPQ 72%, runHNSWRebuild 67%,
  runRefreshDue 50%, runCompactIndex 77%, runCrawlStatus 75%,
  runPebbleInfo 80%, handleSearch 53%, handleFindSimilar 52%,
  handleAnswer 50%, handleResearch 58%, handleQuery 81%,
  paraphraseQuery 87%, applyMMRPermutation 90%, parseQueryPlan 91%,
  parseRetrievalFilters 100%, retrievalFilters.allow 100%,
  sortHitsByDate 90%, truncateForPromptLite 100%, doChat 86%,
  toValues 100%, handleAnswerPOST, handleResearchPOST,
  handleFindSimilarPOST, handleDomains, handleQueue.

New file only (cmd/cosift/zz_round3_test.go); no production source
touched.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TeoSlayer TeoSlayer merged commit 0f0a5ff into main May 28, 2026
3 checks passed
@TeoSlayer TeoSlayer deleted the cosift-cmd-round3 branch May 28, 2026 02:30
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