diff --git a/blastmud_game/src/services/capacity.rs b/blastmud_game/src/services/capacity.rs index 5bee7d1e..bf0c7738 100644 --- a/blastmud_game/src/services/capacity.rs +++ b/blastmud_game/src/services/capacity.rs @@ -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); + } }