pub struct TestContextBuilder { /* private fields */ }Expand description
Builder for creating test contexts with configurable providers.
§Example
use xerv_core::testing::TestContextBuilder;
let ctx = TestContextBuilder::new()
.with_fixed_time("2024-01-15T10:30:00Z")
.with_mock_http(
MockHttp::new()
.on_get("https://api.example.com/status")
.respond_json(200, serde_json::json!({"ok": true}))
)
.with_seed(42)
.with_sequential_uuids()
.with_env_vars(&[("DEBUG", "true")])
.with_secrets(&[("API_KEY", "test-key")])
.with_recording()
.build()
.unwrap();Implementations§
Source§impl TestContextBuilder
impl TestContextBuilder
Sourcepub fn with_trace_id(self, trace_id: TraceId) -> Self
pub fn with_trace_id(self, trace_id: TraceId) -> Self
Set the trace ID.
Sourcepub fn with_node_id(self, node_id: NodeId) -> Self
pub fn with_node_id(self, node_id: NodeId) -> Self
Set the node ID.
Sourcepub fn with_arena_config(self, config: ArenaConfig) -> Self
pub fn with_arena_config(self, config: ArenaConfig) -> Self
Set the arena configuration.
Sourcepub fn with_wal_config(self, config: WalConfig) -> Self
pub fn with_wal_config(self, config: WalConfig) -> Self
Set the WAL configuration.
Sourcepub fn with_fixed_time(self, iso_time: &str) -> Self
pub fn with_fixed_time(self, iso_time: &str) -> Self
Use a fixed time.
Sourcepub fn with_mock_clock(self) -> Self
pub fn with_mock_clock(self) -> Self
Use a mock clock starting at time zero.
Sourcepub fn with_clock(self, clock: Arc<dyn ClockProvider>) -> Self
pub fn with_clock(self, clock: Arc<dyn ClockProvider>) -> Self
Use a custom clock provider.
Sourcepub fn with_real_clock(self) -> Self
pub fn with_real_clock(self) -> Self
Use the real system clock.
Sourcepub fn with_mock_http(self, mock: MockHttp) -> Self
pub fn with_mock_http(self, mock: MockHttp) -> Self
Use a mock HTTP provider.
Sourcepub fn with_http(self, http: Arc<dyn HttpProvider>) -> Self
pub fn with_http(self, http: Arc<dyn HttpProvider>) -> Self
Use a custom HTTP provider.
Sourcepub fn with_real_http(self) -> Self
pub fn with_real_http(self) -> Self
Use the real HTTP provider.
Sourcepub fn with_rng(self, rng: Arc<dyn RngProvider>) -> Self
pub fn with_rng(self, rng: Arc<dyn RngProvider>) -> Self
Use a custom RNG provider.
Sourcepub fn with_real_rng(self) -> Self
pub fn with_real_rng(self) -> Self
Use the real RNG.
Sourcepub fn with_sequential_uuids(self) -> Self
pub fn with_sequential_uuids(self) -> Self
Use sequential UUIDs (00000001, 00000002, …).
Sourcepub fn with_predetermined_uuids(self, uuids: &[&str]) -> Self
pub fn with_predetermined_uuids(self, uuids: &[&str]) -> Self
Use predetermined UUIDs.
Sourcepub fn with_uuid(self, uuid: Arc<dyn UuidProvider>) -> Self
pub fn with_uuid(self, uuid: Arc<dyn UuidProvider>) -> Self
Use a custom UUID provider.
Sourcepub fn with_real_uuid(self) -> Self
pub fn with_real_uuid(self) -> Self
Use the real UUID provider.
Sourcepub fn with_memory_fs(self) -> Self
pub fn with_memory_fs(self) -> Self
Use an in-memory filesystem.
Sourcepub fn with_mock_fs(self, mock: MockFs) -> Self
pub fn with_mock_fs(self, mock: MockFs) -> Self
Use a mock filesystem with predefined files.
Sourcepub fn with_fs(self, fs: Arc<dyn FsProvider>) -> Self
pub fn with_fs(self, fs: Arc<dyn FsProvider>) -> Self
Use a custom filesystem provider.
Sourcepub fn with_real_fs(self) -> Self
pub fn with_real_fs(self) -> Self
Use the real filesystem.
Sourcepub fn with_env_vars(self, vars: &[(&str, &str)]) -> Self
pub fn with_env_vars(self, vars: &[(&str, &str)]) -> Self
Use mock environment variables.
Sourcepub fn with_mock_env(self, mock: MockEnv) -> Self
pub fn with_mock_env(self, mock: MockEnv) -> Self
Use a mock environment provider.
Sourcepub fn with_env(self, env: Arc<dyn EnvProvider>) -> Self
pub fn with_env(self, env: Arc<dyn EnvProvider>) -> Self
Use a custom environment provider.
Sourcepub fn with_real_env(self) -> Self
pub fn with_real_env(self) -> Self
Use the real environment.
Sourcepub fn with_secrets(self, secrets: &[(&str, &str)]) -> Self
pub fn with_secrets(self, secrets: &[(&str, &str)]) -> Self
Use mock secrets.
Sourcepub fn with_mock_secrets(self, mock: MockSecrets) -> Self
pub fn with_mock_secrets(self, mock: MockSecrets) -> Self
Use a mock secrets provider.
Sourcepub fn with_secrets_provider(self, secrets: Arc<dyn SecretsProvider>) -> Self
pub fn with_secrets_provider(self, secrets: Arc<dyn SecretsProvider>) -> Self
Use a custom secrets provider.
Sourcepub fn with_recording(self) -> Self
pub fn with_recording(self) -> Self
Enable event recording.
Sourcepub fn build(self) -> Result<TestContext>
pub fn build(self) -> Result<TestContext>
Build the test context.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestContextBuilder
impl !RefUnwindSafe for TestContextBuilder
impl Send for TestContextBuilder
impl Sync for TestContextBuilder
impl Unpin for TestContextBuilder
impl !UnwindSafe for TestContextBuilder
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.