From 25288a1035e0c9fbb63289f145ccd245bc170bb1 Mon Sep 17 00:00:00 2001 From: Aevyrie Roessler Date: Wed, 5 Jan 2022 13:03:53 -0800 Subject: [PATCH 1/3] Add unit test --- crates/bevy_asset/Cargo.toml | 7 +++++-- crates/bevy_asset/src/assets.rs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index dd37b3e7b530a..c2699b6a3ce86 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -18,7 +18,9 @@ bevy_app = { path = "../bevy_app", version = "0.5.0" } bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.5.0" } bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" } bevy_log = { path = "../bevy_log", version = "0.5.0" } -bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = ["bevy"] } +bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = [ + "bevy", +] } bevy_tasks = { path = "../bevy_tasks", version = "0.5.0" } bevy_utils = { path = "../bevy_utils", version = "0.5.0" } @@ -34,7 +36,7 @@ rand = "0.8.0" [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { version = "0.2" } -web-sys = { version = "0.3", features = ["Request", "Window", "Response"]} +web-sys = { version = "0.3", features = ["Request", "Window", "Response"] } wasm-bindgen-futures = "0.4" js-sys = "0.3" @@ -44,3 +46,4 @@ ndk-glue = { version = "0.5" } [dev-dependencies] futures-lite = "1.4.0" tempfile = "3.2.0" +bevy_core = { path = "../bevy_core", version = "0.5.0" } diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 5d56bb1a6ddbb..80511e2a31ff2 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -309,3 +309,19 @@ impl AddAsset for App { self } } + +#[test] +fn asset_overwriting() { + #[derive(bevy_reflect::TypeUuid)] + #[uuid = "44115972-f31b-46e5-be5c-2b9aece6a52f"] + struct MyAsset; + let mut app = App::new(); + app.add_plugin(bevy_core::CorePlugin) + .add_plugin(crate::AssetPlugin); + app.add_asset::(); + let mut assets_before = app.world.get_resource_mut::>().unwrap(); + let handle = assets_before.add(MyAsset); + app.add_asset::(); // Ensure this doesn't overwrite the Asset + let assets_after = app.world.get_resource_mut::>().unwrap(); + assert!(assets_after.get(handle).is_some()) +} From c9d1e7026f493ef46a90e8ddac0dfff73c59b112 Mon Sep 17 00:00:00 2001 From: Aevyrie Roessler Date: Wed, 5 Jan 2022 13:10:57 -0800 Subject: [PATCH 2/3] Undo formatting linebreak --- crates/bevy_asset/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index c2699b6a3ce86..fb9a01dff3a21 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -18,9 +18,7 @@ bevy_app = { path = "../bevy_app", version = "0.5.0" } bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.5.0" } bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" } bevy_log = { path = "../bevy_log", version = "0.5.0" } -bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = [ - "bevy", -] } +bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = ["bevy",] } bevy_tasks = { path = "../bevy_tasks", version = "0.5.0" } bevy_utils = { path = "../bevy_utils", version = "0.5.0" } From f2d475fa3ee169bd5bbe60b044041ef68480239a Mon Sep 17 00:00:00 2001 From: Aevyrie Roessler Date: Wed, 5 Jan 2022 13:11:25 -0800 Subject: [PATCH 3/3] remove comma in cargo --- crates/bevy_asset/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index fb9a01dff3a21..9127d0862036d 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -18,7 +18,7 @@ bevy_app = { path = "../bevy_app", version = "0.5.0" } bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.5.0" } bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" } bevy_log = { path = "../bevy_log", version = "0.5.0" } -bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = ["bevy",] } +bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = ["bevy"] } bevy_tasks = { path = "../bevy_tasks", version = "0.5.0" } bevy_utils = { path = "../bevy_utils", version = "0.5.0" }