Extract FileSystem to a trait for better testability
Added some tests around filtering and searching by Tags. Added the ability to use an in-memory Sqlite DB for more integration tests.
This commit is contained in:
@@ -27,6 +27,24 @@ impl SqliteUserDao {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use diesel::{Connection, SqliteConnection};
|
||||
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
||||
|
||||
const DB_MIGRATIONS: EmbeddedMigrations = embed_migrations!();
|
||||
|
||||
pub fn in_memory_db_connection() -> SqliteConnection {
|
||||
let mut connection = SqliteConnection::establish(":memory:")
|
||||
.expect("Unable to create in-memory db connection");
|
||||
connection
|
||||
.run_pending_migrations(DB_MIGRATIONS)
|
||||
.expect("Failure running DB migrations");
|
||||
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
impl UserDao for SqliteUserDao {
|
||||
// TODO: Should probably use Result here
|
||||
fn create_user(&mut self, user: &str, pass: &str) -> Option<User> {
|
||||
|
||||
Reference in New Issue
Block a user