Skip to content

test: AlloyDB - increase unit tests coverage - #3799

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

test: AlloyDB - increase unit tests coverage#3799
julian-risch wants to merge 1 commit into
mainfrom
test/alloydb-unit-coverage

Conversation

@julian-risch

Copy link
Copy Markdown
Member

Related Issues

Proposed Changes:

  • Add unit tests for twelve SQL builders that had no test reference at all, asserting the SQL they render rather than mocking them out.
  • Cover the scalar comparison operators in filters.py (>, >=, <, <=, in, not in, like, not like) and AlloyDBKeywordRetriever.from_dict, which had no test.
  • Drive the database-facing methods through a mocked connection and cursor. A second fixture patches only _ensure_db_setup, 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:alloydb type:documentation Improvements or additions to documentation labels Aug 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (alloydb)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/alloydb/src/haystack_integrations/components/retrievers/alloydb
  embedding_retriever.py
  keyword_retriever.py
  integrations/alloydb/src/haystack_integrations/document_stores/alloydb
  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.

Twelve 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 every vector function and its
  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 and embedding retrieval queries, including the score
  operator each vector function uses, and the three rejections in
  _check_and_build_embedding_retrieval_query of which only one was covered
- the result post-processors and the metadata type inference

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 a mocked connection and cursor,
asserting the SQL and parameters handed to execute. A second fixture
patches only _ensure_db_setup, 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.

Both retrievers' run methods and AlloyDBKeywordRetriever.from_dict, which
had no test, are covered with a mocked store.

_ensure_db_setup is deliberately left to the integration tests.

Unit coverage: 42% -> 91%.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@julian-risch
julian-risch force-pushed the test/alloydb-unit-coverage branch from 98d569f to 467d6d9 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:alloydb type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant