From 52c67fef41ff37ed44fe62dd9f8f0fcd403517a5 Mon Sep 17 00:00:00 2001 From: Zicklag Date: Thu, 28 Jan 2021 18:56:22 -0600 Subject: [PATCH] Fix Bug in Asset Server Error Message Formatter --- crates/bevy_asset/src/asset_server.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index 42839f99c6a68..daa10a4b31150 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -30,7 +30,7 @@ pub enum AssetServerError { } fn format_missing_asset_ext(exts: &[String]) -> String { - if exts.is_empty() { + if !exts.is_empty() { format!( " for the following extension{}: {}", if exts.len() > 1 { "s" } else { "" }, @@ -572,6 +572,28 @@ mod test { ) } + #[test] + fn missing_asset_loader_error_messages() { + assert_eq!( + AssetServerError::MissingAssetLoader { extensions: vec![] }.to_string(), + "no `AssetLoader` found" + ); + assert_eq!( + AssetServerError::MissingAssetLoader { + extensions: vec!["png".into()] + } + .to_string(), + "no `AssetLoader` found for the following extension: png" + ); + assert_eq!( + AssetServerError::MissingAssetLoader { + extensions: vec!["1.2.png".into(), "2.png".into(), "png".into()] + } + .to_string(), + "no `AssetLoader` found for the following extensions: 1.2.png, 2.png, png" + ); + } + #[test] fn filename_with_dots() { let asset_server = setup();