Skip to content

test: add unit and integration tests for search service#5024

Merged
fernandolins merged 10 commits into
mainfrom
test/search-service
Jun 17, 2026
Merged

test: add unit and integration tests for search service#5024
fernandolins merged 10 commits into
mainfrom
test/search-service

Conversation

@fernandolins

Copy link
Copy Markdown
Contributor

Linked issue

Closes #4926

Summary / motivation

rslib/src/search/service/ had no test coverage. This PR adds tests across two files (mod.rs and search_node.rs), covering:

  • TryFrom<SearchNode> proto → domain conversions for all filter variants
  • From<Rating> and From<CardState> conversions
  • SearchService RPC methods: build_search_string, search_cards, browser_row_for_id, replace_search_node
  • SortMode construction from proto, including the Custom fallback
  • Error path: build_search_string with an empty group returns InvalidInput
  • Exact-match integration tests for deck, tag, and note-type filters in search_cards

How to test

just test-rust

@fernandolins fernandolins requested a review from abdnh June 16, 2026 20:58
@read-the-docs-community

read-the-docs-community Bot commented Jun 17, 2026

Copy link
Copy Markdown

Documentation build overview

📚 Anki | 🛠️ Build #33186303 | 📁 Comparing 4c6ed8f against latest (2fcaa56)

  🔍 Preview build  

5 files changed · ± 5 modified

± Modified

Comment thread rslib/src/search/service/mod.rs Outdated

#[test]
fn build_search_string_converts_tag_node_to_anki_syntax() {
let (mut col, _tempdir) = open_fs_test_collection("search_service");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need for open_fs_test_collection() in any of the tests? You can use Collection::new().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for catching this!

@fernandolins fernandolins merged commit d13f487 into main Jun 17, 2026
7 checks passed
@fernandolins fernandolins deleted the test/search-service branch June 17, 2026 16:50
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.

test(rust): add tests for the search service layer

2 participants