adds test

This commit is contained in:
2019-07-15 15:25:49 +02:00
parent 58f39ae5d0
commit 96f8e36c97

View File

@@ -272,6 +272,26 @@ mod tests {
assert_eq!(group.name, "Groupe".to_string());
}
#[test]
fn test_player_updates_wealth() {
let conn = test_connection();
DbApi::with_conn(&conn).as_admin()
.add_player("PlayerName".to_string(), 403.21)
.unwrap();
let diff = DbApi::with_conn(&conn).as_player(1)
.update_wealth(-401.21).unwrap()
.response.unwrap();
// Check the returned diff
assert_eq!(diff, (-1, -2, -1, -4));
let players = DbApi::with_conn(&conn).fetch_players().unwrap();
let player = players.get(1).unwrap();
// Check that we can add old value to return diff to get resulting value
assert_eq!(
(player.cp, player.sp, player.gp, player.pp),
(1 + diff.0, 2 + diff.1, 3 + diff.2, 4 + diff.3)
);
}
#[test]
fn test_add_player() {
let conn = test_connection();