Skip to content

Commit

Permalink
Fix Bug in Asset Server Error Message Formatter (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag authored Jan 29, 2021
1 parent 8e69ff2 commit af67231
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { "" },
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit af67231

Please sign in to comment.