Skip to main content

Module testing

Module testing 

Source
Expand description

Shared test utilities for the workspace.

Available unconditionally to keep the surface usable from binary crates, integration tests, and benches. Helpers fall in two buckets:

  1. Builders: LeafBuilder, with_children — build Plan values without repeating boilerplate ..Default::default() blocks.
  2. Assertions: assert_contains_all, strip_ansi, node_count — encapsulate the multi-line patterns that #[test] files in tests/ keep re-implementing.

These are intended for testing only but are exposed publicly so the rustcmdpev binary’s integration tests can reuse them via the workspace dependency.

Structs§

LeafBuilder
Builder for a leaf Plan with the most common fields populated.

Functions§

assert_contains_all
Assert that text contains every needle in needles. Reports the first missing needle with a snippet of the surrounding text so failures point at the exact missing token instead of a wall of text.
assert_contains_none
Assert that text contains none of the substrings in needles.
collect_nodes
Recursively collect every node in a plan tree (depth-first, parent-first).
explain_for
Build a single-plan Explain with optional execution/total cost.
node_count
Recursively count nodes in a plan tree.
strip_ansi
Strip ANSI escape sequences from input for resilient text assertions.
with_children
Wrap parent so it has children attached.