Struct sea_orm::MockDatabase
source · pub struct MockDatabase { /* private fields */ }
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(self, vec: Vec<MockExecResult>) -> Self
pub fn append_exec_results(self, vec: Vec<MockExecResult>) -> Self
Add some MockExecResults to exec_results
sourcepub fn append_query_results<T>(self, vec: Vec<Vec<T>>) -> Selfwhere
T: IntoMockRow,
pub fn append_query_results<T>(self, vec: Vec<Vec<T>>) -> Selfwhere
T: IntoMockRow,
Add some Values to query_results
sourcepub fn append_exec_errors(self, vec: Vec<DbErr>) -> Self
pub fn append_exec_errors(self, vec: Vec<DbErr>) -> Self
Add some DbErrs to exec_results
sourcepub fn append_query_errors(self, vec: Vec<DbErr>) -> Self
pub fn append_query_errors(self, vec: Vec<DbErr>) -> Self
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