Skip to content

test: cover search_with_snippets/5 and search_prefix/4#30

Merged
nyo16 merged 2 commits into
masterfrom
add-snippets-prefix-tests
Jun 14, 2026
Merged

test: cover search_with_snippets/5 and search_prefix/4#30
nyo16 merged 2 commits into
masterfrom
add-snippets-prefix-tests

Conversation

@nyo16

@nyo16 nyo16 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the test gap found during the 0.5.5 smoke test: Searcher.search_with_snippets/5
(plain highlighting) and Searcher.search_prefix/4 (typeahead) were public API
with no direct coverage — only their fuzzy variants (search_fuzzy_with_snippets,
search_fuzzy_prefix) were tested. Both work; they just weren't guarded against
regressions.

What's added

Two dedicated test files, following the existing per-feature convention
(count_test.exs, regex_query_test.exs, …), async: true, test_path setup
with TestHelpers.safe_rm_rf:

test/muninn/snippets_test.exssearch_with_snippets/5

  • returns a snippet map for the requested field
  • highlights the matched term with <b> tags
  • supports multiple snippet fields
  • max_snippet_chars truncates long content
  • limit (documents that total_hits reflects the returned/capped count)

test/muninn/prefix_test.exssearch_prefix/4

  • matches documents by term prefix (excludes non-matches)
  • narrows results as the prefix grows (typeahead)
  • respects the limit option
  • returns no hits for a non-matching prefix

Verification

MUNINN_BUILD=true mix test245 passed (1 doctest, 244 tests), +9 new.

nyo16 added 2 commits June 13, 2026 21:32
These two public Searcher functions had no direct tests — only their
fuzzy variants (search_fuzzy_with_snippets, search_fuzzy_prefix) were
covered. Add dedicated test files following the existing per-feature
convention:

- snippets_test.exs: snippet map shape, <b> highlighting, multiple
  snippet fields, max_snippet_chars truncation, limit (total_hits
  reflects the returned/capped count)
- prefix_test.exs: prefix matching, typeahead narrowing, limit, no-match

Full suite: 245 passed.
total_hits equals length(hits) and is capped by :limit across all search
functions (every collector is TopDocs::with_limit). Add a note to
search_query/4, search_with_snippets/5, and search_prefix/4 pointing to
count/3 for the full match count regardless of limit.
@nyo16 nyo16 merged commit 57f1554 into master Jun 14, 2026
3 checks passed
@nyo16 nyo16 deleted the add-snippets-prefix-tests branch June 14, 2026 01:38
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.

1 participant