refactors claims unit tests

This commit is contained in:
2019-10-15 14:16:45 +02:00
parent de4aad5679
commit 8399ffebf7
3 changed files with 98 additions and 9 deletions

View File

@@ -15,6 +15,12 @@ pub mod models;
//mod updates;
mod schema;
pub use models::{
item::{Item, LootManager},
claim::{Claim, Claims},
player::{Player, Players},
};
/// The connection used
pub type DbConnection = SqliteConnection;
/// A pool of connections
@@ -226,13 +232,9 @@ impl<'q> AsAdmin<'q> {
///
/// Takes the player name and starting wealth (in gold value).
pub fn add_player(self, name: &str, start_wealth: f32) -> ActionResult<()> {
diesel::insert_into(schema::players::table)
.values(&models::player::NewPlayer::create(name, start_wealth))
.execute(self.0)
.map(|rows_updated| match rows_updated {
1 => (),
_ => panic!("RuntimeError: AddPlayer did not make expected changes"),
})
models::player::Players(self.0)
.add(name, start_wealth)?;
Ok(())
}
/// Adds a list of items to the group loot
@@ -280,8 +282,8 @@ pub fn create_pool() -> Pool {
.expect("Failed to create pool.")
}
#[cfg(test)]
mod tests {
#[cfg(none)]
mod tests_old {
use super::*;
type TestConnection = DbConnection;