pub struct EventRecorder { /* private fields */ }Expand description
Recorder for capturing events during test execution.
Thread-safe and can be shared across async tasks.
§Example
use xerv_core::testing::{EventRecorder, RecordedEvent};
let recorder = EventRecorder::new();
recorder.record(RecordedEvent::ClockNow { nanos: 1000 });
recorder.record(RecordedEvent::UuidGenerated { uuid: "test-uuid".to_string() });
let events = recorder.events();
assert_eq!(events.len(), 2);
let json = recorder.to_json();
assert!(json.contains("clock_now"));Implementations§
Source§impl EventRecorder
impl EventRecorder
Sourcepub fn record(&self, event: RecordedEvent)
pub fn record(&self, event: RecordedEvent)
Record an event.
Sourcepub fn events(&self) -> Vec<RecordedEvent>
pub fn events(&self) -> Vec<RecordedEvent>
Get all recorded events.
Sourcepub fn set_enabled(&self, enabled: bool)
pub fn set_enabled(&self, enabled: bool)
Enable or disable recording.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if recording is enabled.
Sourcepub fn to_json_compact(&self) -> String
pub fn to_json_compact(&self) -> String
Convert recorded events to compact JSON.
Sourcepub fn events_of_type(&self, event_type: &str) -> Vec<RecordedEvent>
pub fn events_of_type(&self, event_type: &str) -> Vec<RecordedEvent>
Filter events by type.
Sourcepub fn find<F>(&self, predicate: F) -> Vec<RecordedEvent>
pub fn find<F>(&self, predicate: F) -> Vec<RecordedEvent>
Find events matching a predicate.
Sourcepub fn assert_recorded(&self, event_type: &str) -> bool
pub fn assert_recorded(&self, event_type: &str) -> bool
Assert that an event of the given type was recorded.
Sourcepub fn assert_http_request(&self, method: &str, url_pattern: &str) -> bool
pub fn assert_http_request(&self, method: &str, url_pattern: &str) -> bool
Assert that a specific HTTP request was made.
Sourcepub fn http_requests(&self) -> Vec<(String, String)>
pub fn http_requests(&self) -> Vec<(String, String)>
Get all HTTP requests.
Sourcepub fn generated_uuids(&self) -> Vec<Uuid>
pub fn generated_uuids(&self) -> Vec<Uuid>
Get all generated UUIDs.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EventRecorder
impl !RefUnwindSafe for EventRecorder
impl Send for EventRecorder
impl Sync for EventRecorder
impl Unpin for EventRecorder
impl UnwindSafe for EventRecorder
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Mutably borrows from an owned value. Read more
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>
Returns the layout of the type.
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
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.