Skip to content

test(drive): improve coverage for query conditions and filter matching#3441

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/drive-query-conditions-filter
Apr 7, 2026
Merged

test(drive): improve coverage for query conditions and filter matching#3441
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/drive-query-conditions-filter

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented Apr 7, 2026

Summary

Adds 102 tests across 2 files in rs-drive covering query condition evaluation and document subscription filtering.

File New Tests What's covered
query/conditions.rs 60 sql_value_to_platform_value, from_components parsing, less_than comparisons, value_shape_ok validation, ValueClause::matches_value, WhereOperator::eval
query/filter.rs 42 validate() for all transition types, matches_original_document, evaluate_clauses, get_value_by_path

Test plan

  • cargo test -p drive --lib — 1985 passed
  • cargo fmt --all clean
  • CI

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for query condition evaluation and document filtering functionality to enhance system robustness and reliability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added this to the v3.1.0 milestone Apr 7, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

The PR adds extensive unit test coverage to the query condition and filter modules, expanding test assertions for SQL value conversion, where clause parsing, operator validation, and document query filtering across multiple operator types and edge cases. No production code changes.

Changes

Cohort / File(s) Summary
Query Condition Tests
packages/rs-drive/src/query/conditions.rs
Added 678 lines of unit tests covering SQL value conversion, where clause parsing, operator behavior validation (Between, range comparisons, In, StartsWith), value matching logic across operators, and edge cases for numeric types and boundary conditions.
Query Filter Tests
packages/rs-drive/src/query/filter.rs
Added 948 lines of unit tests covering document query filter validation, clause type/operator compatibility (Transfer, Purchase, UpdatePrice), primary-key constraints, field traversal, runtime evaluation behavior, and error cases for invalid configurations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 A bouncing bundle of tests so fine,
Where clauses dance and conditions align,
From values to filters, the assertions ring true,
Coverage blooms fresh—hooray! (✓✓✓) ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding comprehensive test coverage for query conditions and filter matching functionality in the drive module.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/drive-query-conditions-filter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 7, 2026

Review Gate

Commit: 51f3e040

  • Debounce: 68m ago (need 30m)

  • CI checks: builds passed, 0/2 tests passed

  • CodeRabbit review: comment found

  • Off-peak hours: peak window (5am-11am PT) — currently 06:22 AM PT Tuesday

  • Run review now (check to override)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 99.75248% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.76%. Comparing base (8a83981) to head (51f3e04).
⚠️ Report is 4 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
packages/rs-drive/src/query/conditions.rs 99.36% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3441      +/-   ##
============================================
+ Coverage     80.66%   80.76%   +0.10%     
============================================
  Files          2852     2852              
  Lines        285371   286583    +1212     
============================================
+ Hits         230190   231463    +1273     
+ Misses        55181    55120      -61     
Components Coverage Δ
dpp 73.28% <ø> (ø)
drive 82.74% <99.75%> (+0.24%) ⬆️
drive-abci 86.70% <ø> (ø)
sdk 36.55% <ø> (ø)
dapi-client 79.06% <ø> (ø)
platform-version ∅ <ø> (∅)
platform-value 90.85% <ø> (+0.06%) ⬆️
platform-wallet 76.09% <ø> (ø)
drive-proof-verifier 55.26% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/rs-drive/src/query/filter.rs (1)

1749-2691: Optional: extract common fixture/filter builders for test ergonomics.

There’s substantial repeated setup for contract/filter scaffolding; small helpers would reduce noise and make intent-focused assertions stand out.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive/src/query/filter.rs` around lines 1749 - 2691, Extract
small test helpers to reduce repetition: create a helper that wraps
get_data_contract_fixture and returns the contract (used across tests), and one
or more builder functions to construct DriveDocumentQueryFilter instances for a
given document_type_name and DocumentActionMatchClauses (e.g., helper like
make_contract_fixture() and make_filter(document_type_name, action_clauses)).
Update tests to call these helpers and to construct InternalClauses /
ValueClause inputs via small factory helpers (e.g., build_value_clause,
build_internal_clauses) so repeated boilerplate around
get_data_contract_fixture, DriveDocumentQueryFilter, DocumentActionMatchClauses,
InternalClauses, and ValueClause is centralized and tests become concise.
packages/rs-drive/src/query/conditions.rs (1)

3991-4099: Optional: reduce duplication in equal-value less_than tests.

These cases are clear, but a table-driven helper would keep the suite easier to maintain as value variants evolve.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive/src/query/conditions.rs` around lines 3991 - 4099, The
tests duplicate the same equal-value less_than assertions across many Value
variants; refactor by creating a table-driven helper that accepts a Value and
the test name, then iterates over a list of (Value::U64(10), Value::U32(5),
Value::I32(-3), Value::U16(100), Value::U8(7), Value::I8(-1), Value::U128(999),
Value::Bytes(vec![1,2,3]), Value::Text("same".to_string()), Value::Float(2.5))
and for each constructs a WhereClause (using the existing WhereClause struct and
Equal operator) and asserts less_than(&a, true).unwrap() is true and
less_than(&a, false).unwrap() is false; replace the individual test functions
(less_than_*_equal_values_with_allow_eq) with a single parameterized/test helper
that calls the helper for each variant to eliminate duplication while keeping
checks against the less_than method.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/rs-drive/src/query/conditions.rs`:
- Around line 3991-4099: The tests duplicate the same equal-value less_than
assertions across many Value variants; refactor by creating a table-driven
helper that accepts a Value and the test name, then iterates over a list of
(Value::U64(10), Value::U32(5), Value::I32(-3), Value::U16(100), Value::U8(7),
Value::I8(-1), Value::U128(999), Value::Bytes(vec![1,2,3]),
Value::Text("same".to_string()), Value::Float(2.5)) and for each constructs a
WhereClause (using the existing WhereClause struct and Equal operator) and
asserts less_than(&a, true).unwrap() is true and less_than(&a, false).unwrap()
is false; replace the individual test functions
(less_than_*_equal_values_with_allow_eq) with a single parameterized/test helper
that calls the helper for each variant to eliminate duplication while keeping
checks against the less_than method.

In `@packages/rs-drive/src/query/filter.rs`:
- Around line 1749-2691: Extract small test helpers to reduce repetition: create
a helper that wraps get_data_contract_fixture and returns the contract (used
across tests), and one or more builder functions to construct
DriveDocumentQueryFilter instances for a given document_type_name and
DocumentActionMatchClauses (e.g., helper like make_contract_fixture() and
make_filter(document_type_name, action_clauses)). Update tests to call these
helpers and to construct InternalClauses / ValueClause inputs via small factory
helpers (e.g., build_value_clause, build_internal_clauses) so repeated
boilerplate around get_data_contract_fixture, DriveDocumentQueryFilter,
DocumentActionMatchClauses, InternalClauses, and ValueClause is centralized and
tests become concise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c3883eb0-3002-4614-84e1-63d410f5d089

📥 Commits

Reviewing files that changed from the base of the PR and between 8a83981 and 51f3e04.

📒 Files selected for processing (2)
  • packages/rs-drive/src/query/conditions.rs
  • packages/rs-drive/src/query/filter.rs

@QuantumExplorer QuantumExplorer merged commit f1b8d44 into v3.1-dev Apr 7, 2026
41 checks passed
@QuantumExplorer QuantumExplorer deleted the test/drive-query-conditions-filter branch April 7, 2026 13:23
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