Skip to main content

Crate reinhardt_test

Crate reinhardt_test 

Source
Expand description

§Reinhardt Test

Testing utilities for the Reinhardt framework.

§Overview

This crate provides comprehensive testing tools inspired by Django REST Framework, including API clients, request factories, assertions, and TestContainers integration for database testing.

Most functionality is provided by reinhardt-testkit. This crate adds testing utilities that depend on functional crates (reinhardt-auth, reinhardt-admin, reinhardt-pages, reinhardt-tasks).

§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
  • wasm: Enable WASM frontend testing utilities
  • wasm-full: Enable WASM testing with full web-sys features
  • server-fn-test: Enable server function testing utilities
  • tasks: Enable task queue testing utilities
  • admin: Enable admin panel testing utilities
  • e2e: Enable E2E browser testing utilities via fantoccini/WebDriver

Re-exports§

pub use reinhardt_testkit::reinhardt_urls;

Modules§

assertions
Assertion helpers for common test patterns. Additional assertion helpers for testing
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 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
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§

impl_test_model
Helper macro for implementing Model trait with empty Fields for test models

Structs§

APIClient
Test client for making API requests
APIClientBuilder
Builder for creating APIClient with custom configuration
APIRequestFactory
Factory for creating test requests
APITestCase
Base test case for API testing
ApiTestModel
Test model for API view tests
AsyncTeardownGuard
RAII guard for async test resource cleanup using async-dropper
BodyEchoHandler
Test handler that echoes the request body
CallRecord
Call record for tracking function calls
DebugPanel
Debug panel information
DebugToolbar
Debug toolbar
DelayedHandler
Test handler with configurable delay
EchoPathHandler
Simple test handler that echoes the request path
ErrorTestView
Create a view that always returns an error for testing error handling
FactoryBuilder
Simple factory builder
FixtureLoader
Fixture data loader
LargeResponseHandler
Test handler that returns a large response
MethodEchoHandler
Test handler that echoes the request method
MockFunction
Mock function tracker
RequestBuilder
Builder for constructing test requests
RouterHandler
Test handler that returns different responses based on path
ServerRouter
Unified router with hierarchical routing support
SimpleHandler
Simple handler wrapper for testing
SimpleTestView
Create a simple view for testing basic functionality
Spy
Spy for tracking method calls with arguments
SqlQuery
SQL query record
StatusCodeHandler
Test handler that returns specific status codes based on path
SuiteGuard
Guard for suite-wide shared resource
TeardownGuard
RAII guard for automatic test resource cleanup
TestModel
Test model for view tests
TestResponse
Test response wrapper
TimingInfo
Request/Response timing information
WebSocketTestClient
WebSocket test client for integration testing

Enums§

ClientError
Errors that can occur when using the API test client.
DebugEntry
A single entry within a debug panel.
ErrorKind
Kind of error that an ErrorTestView will produce.
FixtureError
Errors that can occur during fixture loading.
HttpVersion
HTTP version configuration for APIClient

Traits§

AsyncTestResource
Async version of TestResource for async setup/teardown
Factory
Factory trait for creating test data
ResponseExt
Extension trait for Response assertions
SuiteResource
Suite-wide shared resource (BeforeAll/AfterAll pattern)
TestResource
Per-test resource with setup and teardown hooks

Functions§

acquire_suite
Acquire suite-wide shared resource
api_client_from_url
Create an APIClient from a server URL string
assert_has_header
Assert response has header
assert_header_contains
Assert header contains substring
assert_header_equals
Assert header value equals expected
assert_no_header
Assert response doesn’t have header
assert_status
Assert response status code
create_api_test_objects
Create test objects for API views
create_insecure_request
Create a mock HTTP request (non-secure)
create_json_request
Create a test request with JSON body
create_large_test_objects
Create a large set of test objects for pagination testing
create_request
Create a test HTTP request
create_request_with_headers
Create a test request with headers
create_request_with_path_params
Create a test request with path parameters
create_response_with_headers
Create a response with custom headers
create_response_with_status
Create a response with custom status code
create_secure_request
Create a mock HTTPS request
create_test_objects
Create test objects for list views
create_test_request
Create a mock HTTP request for testing with secure/insecure mode
create_test_response
Create a mock response for testing
create_view_request
Create a test request with the given parameters
extract_json
Extract and deserialize JSON from a response
get_header
Get header value from response
has_header
Check if response has a specific header
header_contains
Check if header contains substring
header_equals
Check if header has specific value
init_test_logging
Initialize logging for tests (call once)
poll_until
Poll a condition until it becomes true or timeout is reached.
random_test_key
Generate a random test key using UUID
shutdown_test_server
Shuts down a test server gracefully
spawn_test_server
Spawns a test server on a random available port
test_config_value
Generate test configuration data with timestamp
test_server_guard
Create a test server guard with the given router.

Type Aliases§

FixtureResult
Result type for fixture loading operations.