test: add MLT coverage tests for edge cases#114
Conversation
- mlt_with_doc_id_not_found_returns_error: nonexistent doc_id returns empty - mlt_with_like_and_empty_fields_auto_infers_from_like_json: empty fields list auto-inferred from like JSON keys, terms extracted from like content - mlt_with_min_word_length_filters_short_terms: min_word_length=4 filters single-char tokens - mlt_with_max_word_length_filters_long_terms: max_word_length=4 filters tokens longer than threshold - mlt_all_terms_filtered_returns_empty_or_error: all terms filtered by min_term_freq returns empty results All 9 MLT tests in coverage.rs now pass (previously 4, now 9).
|
Warning Review limit reached
More reviews will be available in 13 minutes and 23 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughFive new integration tests extend MLT (More-Like-This) query coverage in the ChangesMLT Query Test Coverage
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
rust/crates/cloudsearch-index/tests/coverage.rs (2)
973-973: ⚡ Quick winComment inaccuracy: reference term should be "rustacean", not "rust".
The comment states
Reference terms: "rust" (from title)but thelikeJSON on line 979 specifies"title": "rustacean", not"rust". The tokenizer will extract "rustacean" as the reference term from the title field. The test still passes because "systems" matches doc1's body, but the comment is misleading.📝 Suggested fix
- // Reference terms: "rust" (from title) and "systems" (from body) + // Reference terms: "rustacean" (from title) and "systems" (from body)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/crates/cloudsearch-index/tests/coverage.rs` at line 973, Update the misleading comment that currently says 'Reference terms: "rust" (from title) and "systems" (from body)' to reflect the actual title value "rustacean" (i.e., change "rust" to "rustacean"); locate the comment near the test that contains the JSON `title`/`body` ("like" JSON) in the coverage test and modify the reference-term text so it correctly lists "rustacean" and "systems".
888-888: ⚡ Quick winTest name is misleading.
The test name says
returns_errorbut the test checks for empty results (total == 0), not an error. Based on context snippet 1 (lib.rs:887-907), whenbuild_mlt_bool_queryreturns an error for a missing doc_id,Index::searchreturns aSearchResponsewithtotal=0and empty hits rather than propagating the error. Consider renaming tomlt_with_doc_id_not_found_returns_empty_resultsfor clarity.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/crates/cloudsearch-index/tests/coverage.rs` at line 888, Rename the test function mlt_with_doc_id_not_found_returns_error to reflect its actual assertion (it expects empty results), e.g., mlt_with_doc_id_not_found_returns_empty_results; update the async test function name and any references to it so it matches the new descriptive name and makes clear it asserts Index::search returns a SearchResponse with total == 0 and empty hits when build_mlt_bool_query can't find the doc_id.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@rust/crates/cloudsearch-index/tests/coverage.rs`:
- Line 973: Update the misleading comment that currently says 'Reference terms:
"rust" (from title) and "systems" (from body)' to reflect the actual title value
"rustacean" (i.e., change "rust" to "rustacean"); locate the comment near the
test that contains the JSON `title`/`body` ("like" JSON) in the coverage test
and modify the reference-term text so it correctly lists "rustacean" and
"systems".
- Line 888: Rename the test function mlt_with_doc_id_not_found_returns_error to
reflect its actual assertion (it expects empty results), e.g.,
mlt_with_doc_id_not_found_returns_empty_results; update the async test function
name and any references to it so it matches the new descriptive name and makes
clear it asserts Index::search returns a SearchResponse with total == 0 and
empty hits when build_mlt_bool_query can't find the doc_id.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 02c52d8d-d733-4b50-930f-fb382c984bd1
📒 Files selected for processing (1)
rust/crates/cloudsearch-index/tests/coverage.rs
- mlt_with_like_and_empty_fields: fix weak >=1 check to verify both docs match (total==2) with correct ranking (doc1 > doc2) - mlt_with_max_word_length: fix weak >=1 check to verify total==1 and doc2 is the only match
Summary
crates/cloudsearch-index/tests/coverage.rs:mlt_with_doc_id_not_found_returns_error: nonexistentdoc_idreturns empty resultsmlt_with_like_and_empty_fields_auto_infers_from_like_json: emptyfieldslist auto-inferred fromlikeJSON keysmlt_with_min_word_length_filters_short_terms:min_word_lengthfilters short tokensmlt_with_max_word_length_filters_long_terms:max_word_lengthfilters long tokensmlt_all_terms_filtered_returns_empty_or_error: all terms filtered bymin_term_freqreturns emptycoverage.rsnow passSummary by CodeRabbit
Tests