Files
anki/rslib
Fernando Lins bfad9474d4 test: cover the decks service layer (#5514)
## Linked issue

Closes #5383

## Summary / motivation

`rslib/src/decks/service.rs`: the Protobuf entry point for all deck
operations, it had 0% test coverage. This PR adds a golden
`#[cfg(test)]` suite that exercises the happy path, error paths,
boundary cases, and key invariants of the `DecksService` layer and its
proto↔domain conversions.

No production code was changed: the module is a thin routing/conversion
layer with no logic that warranted refactoring. Testing at this boundary
is additive rather than duplicative: `reparent_decks`,
`remove_decks_and_child_decks` and the proto↔domain conversions had no
direct unit tests before.

Coverage of `decks/service.rs` goes from **0% → ~99.7% of lines**

## How to test
### Details

- `just check` passes (fmt, clippy, rust_test, and the rest of the
suite).
- Run just this module: `cargo test -p anki decks::service::tests`.
- Coverage inspected with `just test-rust --coverage --html`
- `decks/service.rs` reports ~99.7% line coverage.

Scenarios covered:
- proto↔domain conversions: full-field `Deck` round trip for both kinds,
`missing kind → InvalidInput`, `FilteredDeckForUpdate` field
preservation and `config: None → default`.
- create/retrieve, update (common + kind-specific persistence), rename
with descendant cascade, delete + card removal, reparent (incl.
`new_parent == 0`).
- name/tree listing: `include_filtered`, empty vs non-empty default
skipping, child-name filtering, `deck_tree` counts by `now`, legacy tree
JSON.
- current deck, collapsed-scope isolation, legacy JSON paths (incl.
`preserve_usn_and_mtime`), and filtered-deck build.
- Error paths assert the specific `AnkiError` variant (`NotFound` /
`InvalidInput`), not just `is_err()`.
2026-09-08 17:10:11 -03:00
..
2025-09-01 14:55:49 +10:00
2025-06-27 16:10:12 +07:00
2020-11-01 14:26:58 +10:00
2023-07-02 18:22:44 +10:00
2022-11-27 15:24:20 +10:00
2025-06-29 11:50:49 +07:00

Anki's Rust code.