Skip to content

test: Supabase - increase unit tests coverage - #3796

Draft
julian-risch wants to merge 3 commits into
mainfrom
test/supabase-unit-coverage
Draft

test: Supabase - increase unit tests coverage#3796
julian-risch wants to merge 3 commits into
mainfrom
test/supabase-unit-coverage

Conversation

@julian-risch

Copy link
Copy Markdown
Member

Related Issues

Proposed Changes:

  • Add unit tests for _apply_filters and _apply_condition (both were 0%), exercised through a small recording stand-in for the PostgREST query builder so the tests assert the query that gets generated.
  • Cover _meta_col, _normalize_value, _match_condition, and the client-boundary methods with mocked sync and async clients.
  • Lift the mock-client fixture into tests/conftest.py; it was duplicated verbatim in test_groonga_document_store.py and test_groonga_retriever.py.

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:supabase type:documentation Improvements or additions to documentation labels Aug 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (supabase)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/supabase/src/haystack_integrations/components/downloaders/supabase
  supabase_bucket_downloader.py
  integrations/supabase/src/haystack_integrations/document_stores/supabase
  groonga_document_store.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. Nearly
all of the gap was in groonga_document_store.py.

The filter translation is exercised through a small recording stand-in
for the PostgREST query builder, so the tests assert the query that gets
generated rather than that some method was called:

- _apply_condition: every comparison operator, the null-inclusive
  rewrites for != and "not in" on meta fields, ISO-date handling, and
  all six FilterError paths
- _apply_filters: AND recursion, the OR and NOT expression building
  including the extra is.null clause NOT(field==value) needs, and the
  rejections of nested and inexpressible operators
- _meta_col: the -> vs ->> choice across numbers, text, booleans, None
  and lists; _normalize_value for booleans
- _match_condition / _match_document: the in-memory matching used on
  PGroonga results

The client-boundary methods are driven through mocked sync and async
clients, asserting the calls made rather than round-tripped data:
write_documents for every DuplicatePolicy, filter/count/delete/update by
filter, _groonga_retrieval, table setup including recreate_table, the
warm_up guards, and every async twin.

Also adds the missing warm_up error path for SupabaseBucketDownloader.

Unit coverage: 48% -> 99%.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@julian-risch
julian-risch force-pushed the test/supabase-unit-coverage branch from 0782b60 to 3c727d6 Compare August 18, 2026 09:26
julian-risch and others added 2 commits August 20, 2026 17:48
Applies the review feedback from #3794 to this PR.

- Lift the async mock-client fixture pair into `conftest.py` too. Only the
  sync pair was shared before, so `test_groonga_document_store.py` kept its
  own async pair and the new tests added a third, near-identical one.
- Rename the shared fixtures to `mock_groonga_client` / `mock_groonga_store`
  (plus the async variants). `mock_supabase_client` only ever mocked the
  Groonga store's client, which is misleading now that it sits in a conftest
  shared with the pgvector and bucket-downloader tests.
- Drop `test_groonga_document_store_unit.py` and merge it into
  `test_groonga_document_store.py`. The `_unit` suffix carried no meaning —
  both files were unit tests, the integration ones live in
  `test_groonga_integration.py` — and it split adjacent code paths across
  files: in-memory filter matching was tested in both.
- Split the resulting file, and `TestRetriever`, into focused test classes
  (`TestInit`, `TestWarmUp`, `TestSerde`, `TestRun`, ...).

One duplicate goes away: `test_write_documents_empty` and
`test_writing_nothing_is_a_no_op` asserted the same thing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:supabase type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant