Skip to main content

Module server_fn

Module server_fn 

Source
Expand description

Server function testing utilities. Server function testing utilities.

This module provides comprehensive testing utilities for server functions, including context management, authentication mocking, and assertions.

§Features

  • Enhanced Test Context: DI-based test context with authentication support
  • Mock HTTP: Request/response mocking for server function testing
  • Authentication Mocking: Test user and session simulation
  • Assertions: Server function result assertions
  • Transaction Management: Database transaction utilities for test isolation

Modules§

assert_permissions
Test helper for permission assertions.
assert_status
Assertion module for common HTTP status code checks.
utils
Test database utilities for common operations.

Macros§

server_fn_test_cases
Macro for creating server function test cases.

Structs§

CleanupGuard
Guard that ensures cleanup runs at the end of a test.
CookieOptions
Cookie options for Set-Cookie header.
ExpectedResult
Result builder for testing server function responses.
MockHttpRequest
Mock HTTP request for testing server functions.
MockHttpResponse
Mock HTTP response for testing.
MockSession
A mock session for testing session-based functionality.
ResponseAssertion
Response assertion builder for server functions that return HTTP-like responses.
ServerFnTestContext
Enhanced test context builder for server function testing.
ServerFnTestEnv
The built test environment containing all test state.
TestDataSeeder
Helper for seeding test data.
TestDatabaseConfig
Configuration for test database behavior.
TestSavepoint
Wrapper for managing savepoints within a test.
TestTokenClaims
Token claims for JWT testing.
TestTransaction
A test transaction that automatically rolls back on drop.
TestUser
A test user for simulating authentication in tests.

Enums§

TransactionMode
Transaction mode for test database operations.

Traits§

HasStatusCode
Trait for types that can provide a status code.
ServerFnErrorAssertions
Extension trait for error assertions.
ServerFnResultAssertions
Extension trait for asserting server function results.
TestConnectionExt
Trait for types that can be used as test transaction connections.

Functions§

assert_server_fn_error
Assert that a server function returns an error.
assert_server_fn_error_contains
Assert that a server function error contains the specified message.
assert_server_fn_returns
Assert that a server function returns a specific value.
assert_validation_error
Assert that a validation error occurred for a specific field.
assert_validation_errors
Assert multiple validation errors occurred for the specified fields.