tests: cmd/cosift round-3 — OpenAI mocks + populated Pebble fixture#3
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
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/completionsand/v1/embeddings. Pluggable per-test viaSetChatResponse/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. AmakeServer(mock)helper wires the fixture into apebbleHTTPso handlers can run in-process againsthttptest.Recorderwithout standing up a real listener.Functions moved from 0% → covered
runStats(pebble path)runBenchPQrunHNSWRebuildrunRefreshDuerunCompactIndexrunCrawlStatusrunPebbleInfohandleSearchhandleFindSimilarhandleAnswerhandleResearchhandleQueryhandleAnswerPOST/handleResearchPOST/handleFindSimilarPOSThandleDomains/handleQueueparaphraseQueryapplyMMRPermutationparseQueryPlanparseRetrievalFiltersretrievalFilters.allowsortHitsByDatetruncateForPromptLitesynthRequest.toValuesdoChatConstraints
*_test.gofile (cmd/cosift/zz_round3_test.go, 1290 lines).-race.Test plan
go test -cover -race -count=1 -timeout 180s ./cmd/cosift/...→ 50.5%go vet ./cmd/cosift/...clean