Write more tests for capacity.

This commit is contained in:
Condorra 2023-02-19 14:07:02 +11:00
parent 4652fa52cf
commit 51b4c5847f

View File

@ -56,4 +56,30 @@ mod test {
assert_eq!(check_item_capacity(&mock_db, "player/foo", 10).await.unwrap(),
CapacityLevel::AboveItemLimit);
}
#[tokio::test]
async fn check_item_capacity_should_say_overburdened_if_over() {
let mut mock_db = MockDBTrans::new();
mock_db.expect_get_location_stats()
.withf(|s| s == "player/foo")
.returning(|_| Ok(LocationStats {
total_count: 2,
total_weight: 100,
}));
assert_eq!(check_item_capacity(&mock_db, "player/foo", 1000000).await.unwrap(),
CapacityLevel::OverBurdened);
}
#[tokio::test]
async fn check_item_capacity_should_say_unburdened_when_low_weight() {
let mut mock_db = MockDBTrans::new();
mock_db.expect_get_location_stats()
.withf(|s| s == "player/foo")
.returning(|_| Ok(LocationStats {
total_count: 2,
total_weight: 100,
}));
assert_eq!(check_item_capacity(&mock_db, "player/foo", 50).await.unwrap(),
CapacityLevel::Unburdened);
}
}