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

@@ -22,6 +22,25 @@ pub struct Player {
pub pp: i32,
}
pub struct Players<'q>(pub &'q DbConnection);
impl<'q> Players<'q> {
pub fn all(&self) -> QueryResult<Vec<Player>> {
players::table
.load(self.0)
}
pub fn add(&self, name: &str, wealth: f32) -> QueryResult<Player> {
diesel::insert_into(players::table)
.values(&NewPlayer::create(name, wealth))
.execute(self.0)?;
players::table
.order(players::dsl::id.desc())
.first(self.0)
}
}
pub struct AsPlayer<'q>(pub &'q DbConnection, pub i32);
impl<'q> AsPlayer<'q> {