Struct sea_orm::MockDatabase
source · 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) -> Selfwhere
T: IntoMockRow,
I: IntoIterator<Item = T>,
II: IntoIterator<Item = I>,
pub fn append_query_results<T, I, II>(self, vec: II) -> Selfwhere T: IntoMockRow, I: IntoIterator<Item = T>, II: IntoIterator<Item = I>,
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