fix: Fix interaction and pathfinding tests
This commit is contained in:
@@ -65,7 +65,7 @@ fn test_plant_seed_interaction() {
|
||||
);
|
||||
|
||||
// Run the interaction logic as a system or closure
|
||||
app.world_mut().run_system_once(
|
||||
let _ = app.world_mut().run_system_once(
|
||||
move |grid: Res<Grid>,
|
||||
mut tile_query: Query<&mut TileState>,
|
||||
mut inventory: ResMut<Inventory>,
|
||||
@@ -111,10 +111,6 @@ fn test_plant_seed_interaction() {
|
||||
if let Some(stack) = app.world().entity(*entity).get::<ItemStack>() {
|
||||
assert_eq!(stack.amount, 0, "Item amount should be 0");
|
||||
} else {
|
||||
// Entity might be despawned but still in inventory list until cleanup?
|
||||
// Inventory struct implementation removes it from vector if using update_item_stack properly?
|
||||
// update_item_stack does `self.items.remove(index);`
|
||||
// So the list should be empty.
|
||||
panic!(
|
||||
"Inventory items list should be empty or point to valid 0 amount entities. Found phantom entity."
|
||||
);
|
||||
@@ -137,7 +133,7 @@ fn test_plant_seed_no_inventory() {
|
||||
vec![], // Empty inventory
|
||||
);
|
||||
|
||||
app.world_mut().run_system_once(
|
||||
let _ = app.world_mut().run_system_once(
|
||||
move |grid: Res<Grid>,
|
||||
mut tile_query: Query<&mut TileState>,
|
||||
mut inventory: ResMut<Inventory>,
|
||||
|
||||
@@ -4,12 +4,6 @@ use pomomon_garden::features::pom::utils::find_path;
|
||||
use pomomon_garden::prelude::*;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
const OBSTACLE: TileState = TileState::Occupied {
|
||||
seed: ItemType::BerrySeed {
|
||||
name: "test".into(),
|
||||
},
|
||||
};
|
||||
|
||||
// Helper to set up a Bevy App for pathfinding tests
|
||||
fn setup_pathfinding_app(
|
||||
grid_width: u32,
|
||||
@@ -95,7 +89,16 @@ fn test_find_path_simple() {
|
||||
|
||||
#[test]
|
||||
fn test_find_path_around_obstacle() {
|
||||
let obstacles = vec![(2, 2, OBSTACLE), (2, 3, OBSTACLE), (2, 4, OBSTACLE)];
|
||||
let obstacle: TileState = TileState::Occupied {
|
||||
seed: ItemType::BerrySeed {
|
||||
name: "test".into(),
|
||||
},
|
||||
};
|
||||
let obstacles = vec![
|
||||
(2, 2, obstacle.clone()),
|
||||
(2, 3, obstacle.clone()),
|
||||
(2, 4, obstacle.clone()),
|
||||
];
|
||||
let mut app = setup_pathfinding_app(5, 5, &obstacles);
|
||||
|
||||
let _ = app.world_mut().insert_resource(PathResult(None));
|
||||
@@ -137,12 +140,17 @@ fn test_find_path_around_obstacle() {
|
||||
|
||||
#[test]
|
||||
fn test_find_path_no_path() {
|
||||
let obstacle: TileState = TileState::Occupied {
|
||||
seed: ItemType::BerrySeed {
|
||||
name: "test".into(),
|
||||
},
|
||||
};
|
||||
let obstacles = vec![
|
||||
(2, 0, OBSTACLE),
|
||||
(2, 1, OBSTACLE),
|
||||
(2, 2, OBSTACLE),
|
||||
(2, 3, OBSTACLE),
|
||||
(2, 4, OBSTACLE),
|
||||
(2, 0, obstacle.clone()),
|
||||
(2, 1, obstacle.clone()),
|
||||
(2, 2, obstacle.clone()),
|
||||
(2, 3, obstacle.clone()),
|
||||
(2, 4, obstacle.clone()),
|
||||
];
|
||||
let mut app = setup_pathfinding_app(5, 5, &obstacles);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user