Skip to content

test: Pgvector - increase unit tests coverage - #3800

Draft
julian-risch wants to merge 1 commit into
mainfrom
test/pgvector-unit-coverage
Draft

test: Pgvector - increase unit tests coverage#3800
julian-risch wants to merge 1 commit into
mainfrom
test/pgvector-unit-coverage

Conversation

@julian-risch

Copy link
Copy Markdown
Member

Related Issues

Proposed Changes:

  • Add unit tests for ten SQL builders that had no test reference at all, asserting the SQL they render, including the HNSW index for both the vector and halfvec types.
  • Cover the scalar comparison operators in filters.py (>, >=, <, <=, in, not in, like, not like).
  • Drive the database-facing methods through mocked sync and async connections and cursors. A second fixture patches only the db-setup methods, so _initialize_table, delete_table and _handle_hnsw — which the shared mock_store fixture patches away — are exercised too.

How did you test it?

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes — n/a
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test:.

@github-actions github-actions Bot added integration:pgvector type:documentation Improvements or additions to documentation labels Aug 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (pgvector)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/pgvector/src/haystack_integrations/document_stores/pgvector
  converters.py
  document_store.py
  filters.py
Project Total  

This report was generated by python-coverage-comment-action

Cover the code paths that were only reachable through the
integration-marked tests, which the unit coverage badge excludes.

Ten SQL builders had no test reference at all, even though they return
psycopg Composed objects and need no database. They are now asserted on
the SQL they render, using the _render helper the filter tests already
use:

- table creation, HNSW index creation for both vector and halfvec types
  and their build parameters, and the insert statement for every
  DuplicatePolicy
- the count, count-distinct, min/max and unique-values queries, including
  pagination, the ILIKE search term, and why the unique-values query uses
  -> rather than ->> so numbers sort numerically
- the keyword retrieval query and the three rejections in
  _check_and_build_embedding_retrieval_query

filters.py gains the scalar comparison operators: >, >=, <, <= with their
ISO date handling and type rejections, in/not in, and like/not like. The
not-in test pins the IS NULL clause that keeps rows missing the field.

The database-facing methods run against mocked sync and async connections
and cursors, asserting the SQL and parameters handed to execute, and
covering the DuplicateDocumentError and DocumentStoreError paths. A
second fixture patches only the db-setup methods, so _initialize_table,
delete_table and _handle_hnsw — which the shared mock_store fixture
patches away — are exercised too, including the warning when an HNSW
index already exists. Every async twin is covered alongside its
synchronous counterpart.

_ensure_db_setup and its async twin are deliberately left to the
integration tests.

Unit coverage: 47% -> 92%.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@julian-risch
julian-risch force-pushed the test/pgvector-unit-coverage branch from 28d4e08 to 85f7453 Compare August 18, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:pgvector type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant