From 76db02768e4682e3a36da47db5b54c85bf5d48dd 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 | 31 ++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index 42839f99c6a68d..f1aac87b630f79 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,35 @@ mod test { ) } + #[test] + fn missing_asset_loader_error_messages() { + assert_eq!( + format!( + "{}", + AssetServerError::MissingAssetLoader { extensions: vec![] } + ), + "no `AssetLoader` found" + ); + assert_eq!( + format!( + "{}", + AssetServerError::MissingAssetLoader { + extensions: vec!["png".into()] + } + ), + "no `AssetLoader` found for the following extension: png" + ); + assert_eq!( + format!( + "{}", + AssetServerError::MissingAssetLoader { + extensions: vec!["1.2.png".into(), "2.png".into(), "png".into()] + } + ), + "no `AssetLoader` found for the following extensions: 1.2.png, 2.png, png" + ); + } + #[test] fn filename_with_dots() { let asset_server = setup();