pub struct MockDatabase { /* private fields */ }
Available on crate feature
mock
only.Expand description
Defines a Mock database suitable for testing
Implementationsยง
Sourceยงimpl MockDatabase
impl MockDatabase
Sourcepub fn new(db_backend: DbBackend) -> Self
pub fn new(db_backend: DbBackend) -> Self
Instantiate a mock database with a DbBackend to simulate real world SQL databases
Sourcepub fn into_connection(self) -> DatabaseConnection
pub fn into_connection(self) -> DatabaseConnection
Create a database connection
Sourcepub fn append_exec_results<I>(self, vec: I) -> Selfwhere
I: IntoIterator<Item = MockExecResult>,
pub fn append_exec_results<I>(self, vec: I) -> Selfwhere
I: IntoIterator<Item = MockExecResult>,
Add some MockExecResults to exec_results
Sourcepub fn append_query_results<T, I, II>(self, vec: II) -> Self
pub fn append_query_results<T, I, II>(self, vec: II) -> Self
Add some Values to query_results
Sourcepub fn append_exec_errors<I>(self, vec: I) -> Selfwhere
I: IntoIterator<Item = DbErr>,
pub fn append_exec_errors<I>(self, vec: I) -> Selfwhere
I: IntoIterator<Item = DbErr>,
Add some DbErrs to exec_results
Sourcepub fn append_query_errors<I>(self, vec: I) -> Selfwhere
I: IntoIterator<Item = DbErr>,
pub fn append_query_errors<I>(self, vec: I) -> Selfwhere
I: IntoIterator<Item = DbErr>,
Add some DbErrs to query_results
Trait Implementationsยง
Sourceยงimpl Debug for MockDatabase
impl Debug for MockDatabase
Sourceยงimpl MockDatabaseTrait for MockDatabase
impl MockDatabaseTrait for MockDatabase
Sourceยงfn execute(
&mut self,
counter: usize,
statement: Statement,
) -> Result<ExecResult, DbErr>
fn execute( &mut self, counter: usize, statement: Statement, ) -> Result<ExecResult, DbErr>
Execute a statement in the MockDatabase
Sourceยงfn query(
&mut self,
counter: usize,
statement: Statement,
) -> Result<Vec<QueryResult>, DbErr>
fn query( &mut self, counter: usize, statement: Statement, ) -> Result<Vec<QueryResult>, DbErr>
Execute a SQL query in the MockDatabase
Sourceยงfn commit(&mut self)
fn commit(&mut self)
Commit a successful transaction atomically into the MockDatabase
Sourceยงfn drain_transaction_log(&mut self) -> Vec<Transaction>
fn drain_transaction_log(&mut self) -> Vec<Transaction>
Get all logs from a MockDatabase and return a Transaction
Sourceยงfn get_database_backend(&self) -> DbBackend
fn get_database_backend(&self) -> DbBackend
Get the backend being used in the MockDatabase
Auto Trait Implementationsยง
impl Freeze for MockDatabase
impl !RefUnwindSafe for MockDatabase
impl Send for MockDatabase
impl Sync for MockDatabase
impl Unpin for MockDatabase
impl !UnwindSafe for MockDatabase
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
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> 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