pub struct MockAtprotoClient { /* private fields */ }Expand description
Mock AT Protocol client that records calls and returns scripted responses.
Use this in tests instead of making real network calls.
Implementations§
Source§impl MockAtprotoClient
impl MockAtprotoClient
Sourcepub fn when(&self, method: &str, path: &str) -> &Self
pub fn when(&self, method: &str, path: &str) -> &Self
Script a response for a given method+path combination.
Sourcepub fn returns(&self, method: &str, path: &str, response: Value)
pub fn returns(&self, method: &str, path: &str, response: Value)
Set the response for the most recently configured when.
Sourcepub fn get_record(&self, collection: &str, rkey: &str) -> Result<Value>
pub fn get_record(&self, collection: &str, rkey: &str) -> Result<Value>
Simulate a get_record call.
Sourcepub fn put_record(&self, collection: &str, record: &Value) -> Result<Value>
pub fn put_record(&self, collection: &str, record: &Value) -> Result<Value>
Simulate a put_record call.
Sourcepub fn list_records(&self, collection: &str) -> Result<Value>
pub fn list_records(&self, collection: &str) -> Result<Value>
Simulate a list_records call.
Sourcepub fn delete_record(&self, collection: &str, rkey: &str) -> Result<()>
pub fn delete_record(&self, collection: &str, rkey: &str) -> Result<()>
Simulate a delete_record call.
Sourcepub fn calls(&self) -> Vec<RecordedCall>
pub fn calls(&self) -> Vec<RecordedCall>
Get all recorded calls.
Sourcepub fn assert_called(&self, method: &str, path: &str, n: usize)
pub fn assert_called(&self, method: &str, path: &str, n: usize)
Assert that a specific method+path was called exactly n times.
Sourcepub fn assert_called_any(&self, method: &str)
pub fn assert_called_any(&self, method: &str)
Assert that a method was called at least once (any path).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MockAtprotoClient
impl RefUnwindSafe for MockAtprotoClient
impl Send for MockAtprotoClient
impl Sync for MockAtprotoClient
impl Unpin for MockAtprotoClient
impl UnsafeUnpin for MockAtprotoClient
impl UnwindSafe for MockAtprotoClient
Blanket Implementations§
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more