Skip to main content

Crate wireframe_testing

Crate wireframe_testing 

Source
Expand description

Utilities for driving a WireframeApp with in-memory streams during tests.

These helpers spawn the application on a tokio::io::duplex stream and return all bytes written by the app for easy assertions. They work with any message implementing [serde::Serialize]. The payload is encoded with bincode::encode_to_vec using bincode::config::standard(), which means little-endian byte order, variable-length integer encoding and no byte limit are applied. The example uses a simple u8 value so no generics are required.

use wireframe::app::WireframeApp;
use wireframe_testing::drive_with_bincode;

let bytes = drive_with_bincode(app, 42u8).await.unwrap();

Re-exports§

pub use client_pair::WireframePair;
pub use client_pair::spawn_wireframe_pair;
pub use client_pair::spawn_wireframe_pair_default;
pub use echo_server::ServerMode;
pub use echo_server::process_frame;
pub use helpers::MaxFrameLength;
pub use helpers::PayloadLength;
pub use helpers::TEST_MAX_FRAME;
pub use helpers::TestSerializer;
pub use helpers::TransactionId;
pub use helpers::correlated_hotline_wire;
pub use helpers::decode_frames;
pub use helpers::decode_frames_with_codec;
pub use helpers::decode_frames_with_max;
pub use helpers::drive_with_bincode;
pub use helpers::drive_with_codec_frames;
pub use helpers::drive_with_codec_frames_with_capacity;
pub use helpers::drive_with_codec_payloads;
pub use helpers::drive_with_codec_payloads_mut;
pub use helpers::drive_with_codec_payloads_with_capacity;
pub use helpers::drive_with_codec_payloads_with_capacity_mut;
pub use helpers::drive_with_frame;
pub use helpers::drive_with_frame_mut;
pub use helpers::drive_with_frame_with_capacity;
pub use helpers::drive_with_frames;
pub use helpers::drive_with_frames_mut;
pub use helpers::drive_with_frames_with_capacity;
pub use helpers::drive_with_payloads;
pub use helpers::drive_with_payloads_mut;
pub use helpers::encode_frame;
pub use helpers::encode_payloads_with_codec;
pub use helpers::extract_payloads;
pub use helpers::mismatched_total_size_wire;
pub use helpers::new_test_codec;
pub use helpers::oversized_hotline_wire;
pub use helpers::run_app;
pub use helpers::run_with_duplex_server;
pub use helpers::sequential_hotline_wire;
pub use helpers::truncated_hotline_header;
pub use helpers::truncated_hotline_payload;
pub use helpers::valid_hotline_frame;
pub use helpers::valid_hotline_wire;
pub use integration_helpers::CommonHandler;
pub use integration_helpers::CommonTestApp;
pub use integration_helpers::CommonTestEnvelope;
pub use integration_helpers::Echo;
pub use integration_helpers::TestApp;
pub use integration_helpers::echo_app_factory;
pub use integration_helpers::echo_handler;
pub use integration_helpers::factory;
pub use integration_helpers::factory;
pub use integration_helpers::unused_listener;
pub use logging::LoggerHandle;
pub use logging::logger;
pub use logging::logger;
pub use observability::Labels;
pub use observability::ObservabilityHandle;
pub use observability::obs_handle;
pub use observability::obs_handle;

Modules§

client_pair
In-process server and client pair harness.
echo_server
Echo server utilities for testing client messaging with correlation IDs.
helpers
Helper utilities for driving WireframeApp instances in tests.
integration_helpers
Shared helpers for integration testing Wireframe applications.
logging
Logging utilities for test infrastructure.
macros
Assertion macros shared by test helpers and integration tests.
multi_packet
Helpers for draining Response::MultiPacket values in tests.
observability
Test observability harness for capturing logs and metrics.
reassembly
Compatibility re-exports for wireframe::testkit::reassembly.

Macros§

push_expect
Await a push future and return a contextualized error on failure.
recv_expect
Await a receive future and return a contextualized error on failure.

Structs§

SlowIoConfig
Shared configuration for slow-I/O app driving.
SlowIoPacing
Pacing configuration for one I/O direction.

Enums§

TestError
Error type shared by wireframe::testkit helper APIs.

Constants§

MAX_SLOW_IO_CAPACITY
Maximum duplex capacity supported by the slow-I/O helpers.

Functions§

collect_multi_packet
Collect all frames from a Response::MultiPacket.
drive_with_fragment_frames
Fragment and feed through app, returning decoded response frames.
drive_with_fragments
Fragment payload, encode each fragment into a codec frame, and drive through app.
drive_with_fragments_mut
Fragment and feed through a mutable app.
drive_with_fragments_with_capacity
Fragment and feed with a duplex buffer of capacity bytes.
drive_with_partial_codec_frames
Drive app with payloads in chunks and return decoded response frames.
drive_with_partial_fragments
Fragment payload and feed the wire bytes in chunks of chunk_size.
drive_with_partial_frames
Drive app with payloads encoded by codec, writing wire bytes in chunks.
drive_with_partial_frames_mut
Drive a mutable app with payloads in chunks of chunk_size.
drive_with_partial_frames_with_capacity
Drive app with payloads in chunks using a duplex buffer of capacity.
drive_with_slow_codec_frames
Drive app with codec-encoded payloads using optional slow I/O pacing and return decoded response frames.
drive_with_slow_codec_payloads
Drive app with codec-encoded payloads using optional slow I/O pacing.
drive_with_slow_frames
Drive app with pre-framed bytes using optional slow writer and reader pacing.
drive_with_slow_payloads
Encode payloads with the default length-delimited codec and drive app.

Type Aliases§

TestResult
Shared result type for testkit helpers.