Skip to main content

Crate reinhardt_testkit

Crate reinhardt_testkit 

Source
Expand description

§Reinhardt Testkit

Core testing infrastructure for the Reinhardt framework.

§Overview

This crate provides the foundational testing tools that do not depend on functional crates (reinhardt-auth, reinhardt-admin, reinhardt-tasks, etc.). It is designed to be used as a dependency by functional crates that need test utilities without creating circular dependencies.

For the full testing experience including authentication fixtures and admin panel testing, use reinhardt-test which re-exports everything from this crate plus additional functionality.

§Features

  • APIClient: HTTP client for making test API requests
  • APIRequestFactory: Factory for creating mock HTTP requests
  • APITestCase: Base test case with common assertions
  • Response Assertions: Status, header, and body assertions
  • Factory: Model factory for generating test data
  • DebugToolbar: Debug panel for inspecting queries and timing
  • WebSocketTestClient: WebSocket connection testing
  • TestContainers: Database containers (PostgreSQL, MySQL, Redis) integration

§Feature Flags

  • testcontainers: Enable TestContainers for database testing
  • static: Enable static file testing utilities
  • websockets: Enable WebSocket testing utilities
  • graphql: Enable GraphQL testing utilities
  • property-based: Enable property-based testing with proptest
  • viewsets: Enable viewset testing utilities
  • admin: Enable admin panel testing utilities
  • messages: Enable message framework testing utilities
  • full: Enable all features above

Re-exports§

pub use client::APIClient;
pub use client::APIClientBuilder;
pub use client::ClientError;
pub use client::HttpVersion;
pub use debug::DebugEntry;
pub use debug::DebugPanel;
pub use debug::DebugToolbar;
pub use debug::SqlQuery;
pub use debug::TimingInfo;
pub use factory::APIRequestFactory;
pub use factory::RequestBuilder;
pub use fixtures::Factory;
pub use fixtures::FactoryBuilder;
pub use fixtures::FixtureError;
pub use fixtures::FixtureLoader;
pub use fixtures::FixtureResult;
pub use fixtures::api_client_from_url;
pub use fixtures::random_test_key;
pub use fixtures::test_config_value;
pub use fixtures::test_server_guard;
pub use http::assert_has_header;
pub use http::assert_header_contains;
pub use http::assert_header_equals;
pub use http::assert_no_header;
pub use http::assert_status;
pub use http::create_insecure_request;
pub use http::create_request;
pub use http::create_response_with_headers;
pub use http::create_response_with_status;
pub use http::create_secure_request;
pub use http::create_test_request;
pub use http::create_test_response;
pub use http::extract_json;
pub use http::get_header;
pub use http::has_header;
pub use http::header_contains;
pub use http::header_equals;
pub use logging::init_test_logging;
pub use mock::CallRecord;
pub use mock::MockFunction;
pub use mock::SimpleHandler;
pub use mock::Spy;
pub use resource::AsyncTeardownGuard;
pub use resource::AsyncTestResource;
pub use resource::SuiteGuard;
pub use resource::SuiteResource;
pub use resource::TeardownGuard;
pub use resource::TestResource;
pub use resource::acquire_suite;
pub use response::ResponseExt;
pub use response::TestResponse;
pub use server::BodyEchoHandler;
pub use server::DelayedHandler;
pub use server::EchoPathHandler;
pub use server::LargeResponseHandler;
pub use server::MethodEchoHandler;
pub use server::RouterHandler;
pub use server::StatusCodeHandler;
pub use server::shutdown_test_server;
pub use server::spawn_test_server;
pub use testcase::APITestCase;
pub use views::ApiTestModel;
pub use views::ErrorKind;
pub use views::ErrorTestView;
pub use views::SimpleTestView;
pub use views::TestModel;
pub use views::create_api_test_objects;
pub use views::create_json_request;
pub use views::create_large_test_objects;
pub use views::create_request as create_view_request;
pub use views::create_request_with_headers;
pub use views::create_request_with_path_params;
pub use views::create_test_objects;
pub use websocket::WebSocketTestClient;
pub use reinhardt_urls;
pub use assertions::*;

Modules§

assertions
Assertion helpers for common test patterns. Additional assertion helpers for testing
auth
Test authentication builder and utilities. Test authentication utilities.
client
HTTP client for making test API requests. API Client for testing
debug
Debug toolbar for inspecting queries, timing, and cache.
factory
API request factory for creating mock HTTP requests. Request factory for creating test requests
fixtures
Test fixture loading and management. Test fixtures and utilities for Reinhardt framework testing
http
HTTP request/response helpers for testing. HTTP test utilities for Reinhardt framework
logging
Test logging initialization utilities. Test logging utilities for Reinhardt framework
mock
Mock function and spy utilities for testing.
prelude
Re-export commonly used testing types
resource
Test resource lifecycle management (setup/teardown). Test resource management with automatic setup and teardown
response
Response wrapper with assertion methods. Test response wrapper with assertion helpers
server
Test server spawning and management. HTTP server test utilities
server_fn
Server function testing utilities. Server function testing utilities.
testcase
Base test case with common assertions. Base test case with common setup and assertions
views
Test view implementations for integration testing. View test utilities for Reinhardt framework
websocket
WebSocket testing client. WebSocket test client and utilities for integration testing

Macros§

authenticated_test_case
Helper macro for defining authenticated test cases
impl_test_model
Helper macro for implementing Model trait with empty Fields for test models
server_fn_test_cases
Macro for creating server function test cases.
test_case
Helper macro for defining test cases with automatic setup/teardown
with_di_overrides
Sets up a test InjectionContext with one or more dependencies overridden. See the crate README for usage.

Structs§

ServerRouter
Unified router with hierarchical routing support

Enums§

DependencyScope
Scope for dependency injection
DiError
Errors that can occur during dependency injection resolution.

Functions§

poll_until
Poll a condition until it becomes true or timeout is reached.